Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
keyboardtools.cpp File Reference

input_keys and input_text: keys, shortcuts and typed text. More...

#include "inputtools_p.h"
#include <sonde/guiintegration.h>
#include <sonde/guitools.h>
#include <sonde/objecttree.h>
#include <sonde/schema.h>
#include <QtCore/QElapsedTimer>
#include <QtCore/QPointer>
#include <QtCore/QTimer>
#include <QtGui/QGuiApplication>
#include <QtGui/QKeySequence>
#include <QtGui/QWindow>
#include <array>
#include <climits>
#include <cmath>

Classes

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

Namespaces

namespace  Sonde
 Embeddable Model Context Protocol server for Qt applications.

Functions

void qt_handleMouseEvent (QWindow *window, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods, int timestamp)
 QtGui entry point used by QtTest: delivers a mouse event synchronously through QGuiApplication.
void qt_handleKeyEvent (QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString &text, bool autorep, ushort count)
 QtGui entry point used by QtTest: delivers a key event synchronously through QGuiApplication (shortcuts included).
QString Sonde::anonymous_namespace{keyboardtools.cpp}::textForKey (int key, Qt::KeyboardModifiers mods)
 The text a key press produces (empty with Ctrl/Alt/Meta or for non-printing keys).
void Sonde::anonymous_namespace{keyboardtools.cpp}::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 Sonde::anonymous_namespace{keyboardtools.cpp}::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 * 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.
void Sonde::anonymous_namespace{keyboardtools.cpp}::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 > Sonde::anonymous_namespace{keyboardtools.cpp}::parseKeys (const QString &keys)
 Parses a QKeySequence in portable syntax, rejecting unknown key names.
void Sonde::anonymous_namespace{keyboardtools.cpp}::pressSequence (const QPointer< QWindow > &w, const QKeySequence &seq, int repeat)
 Presses every combination of seq, repeat times.
void Sonde::anonymous_namespace{keyboardtools.cpp}::keyPress (const ToolCall &call)
 The input_keys tool.
TypedKey Sonde::anonymous_namespace{keyboardtools.cpp}::keyForCharacter (const QString &chunk)
 How to type chunk (one character) as a key event.
void Sonde::anonymous_namespace{keyboardtools.cpp}::typeText (const ToolCall &call, const QPointer< QWindow > &w, const QString &text)
 Sends text as key events and finishes the call after settling.
void Sonde::anonymous_namespace{keyboardtools.cpp}::typeTextTool (const ToolCall &call)
 The input_text tool.

Variables

constexpr int Sonde::anonymous_namespace{keyboardtools.cpp}::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.

Detailed Description

input_keys and input_text: keys, shortcuts and typed text.