Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
Sonde::anonymous_namespace{keyboardtools.cpp} Namespace Reference

Classes

struct  TypedKey
 The key code, modifiers and event text that type one character (chunk: a code unit, or a surrogate pair). More...

Functions

QString textForKey (int key, Qt::KeyboardModifiers mods)
 The text a key press produces (empty with Ctrl/Alt/Meta or for non-printing keys).
void sendKey (QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers mods, const QString &text)
 Delivers one key event to w (if it still exists).
void keyClick (QWindow *w, int key, Qt::KeyboardModifiers mods, const QString &text)
 Presses the modifiers, presses and releases the key, then releases the modifiers (as QTest does).
QWindow * keyboardTarget (const QJsonObject &args, QString *error)
 The window that receives keys: the "object" argument's window (after giving that object focus), or the "window" argument's.
void whenActive (const ToolCall &call, const QPointer< QWindow > &window, const std::function< void()> &action)
 Runs action once window is active (or the activation timeout passed).
std::optional< QKeySequence > parseKeys (const QString &keys)
 Parses a QKeySequence in portable syntax, rejecting unknown key names.
void pressSequence (const QPointer< QWindow > &w, const QKeySequence &seq, int repeat)
 Presses every combination of seq, repeat times.
void keyPress (const ToolCall &call)
 The input_keys tool.
TypedKey keyForCharacter (const QString &chunk)
 How to type chunk (one character) as a key event.
void typeText (const ToolCall &call, const QPointer< QWindow > &w, const QString &text)
 Sends text as key events and finishes the call after settling.
void typeTextTool (const ToolCall &call)
 The input_text tool.

Variables

constexpr int kActivationTimeoutMs = 500
 Keyboard events only reach Qt Quick's focus item while its window is active (Qt Widgets does not care), so the window is activated first and the platform gets this long to do it.

Function Documentation

◆ keyboardTarget()

QWindow * Sonde::anonymous_namespace{keyboardtools.cpp}::keyboardTarget ( const QJsonObject & args,
QString * error )

The window that receives keys: the "object" argument's window (after giving that object focus), or the "window" argument's.

Returns
The window, or nullptr with error set.