Lomiri
Loading...
Searching...
No Matches
InputEventGenerator Class Reference

This class allows injecting Key events into the scene it lives in. More...

#include <plugins/Utils/inputeventgenerator.h>

Inherits QQuickItem.

Public Member Functions

 InputEventGenerator (QQuickItem *parent=0)
 
Q_INVOKABLE void generateKeyEvent (Qt::Key key, bool pressed, Qt::KeyboardModifiers modifiers=Qt::NoModifier, quint64 timestamp=QDateTime::currentMSecsSinceEpoch(), quint32 nativeScanCode=0, const QString &text=QString())
 

Detailed Description

This class allows injecting Key events into the scene it lives in.

Definition at line 27 of file inputeventgenerator.h.

Constructor & Destructor Documentation

◆ InputEventGenerator()

InputEventGenerator::InputEventGenerator ( QQuickItem *  parent = 0)

Definition at line 23 of file inputeventgenerator.cpp.

24 : QQuickItem(parent)
25{
26}

Member Function Documentation

◆ generateKeyEvent()

void InputEventGenerator::generateKeyEvent ( Qt::Key  key,
bool  pressed,
Qt::KeyboardModifiers  modifiers = Qt::NoModifier,
quint64  timestamp = QDateTime::currentMSecsSinceEpoch(),
quint32  nativeScanCode = 0,
const QString &  text = QString() 
)

Generate and post and event to the scene. The key event will be sent to the scene the Generator lives in and it will be dispatched through the regular event/focus queue.

Definition at line 28 of file inputeventgenerator.cpp.

29{
30 QEvent::Type type = pressed ? QEvent::KeyPress : QEvent::KeyRelease;
31 QKeyEvent ev(type, key, modifiers, nativeScanCode, 0, 0, text);
32 ev.setTimestamp(timestamp);
33 QCoreApplication::sendEvent(window(), &ev);
34}

The documentation for this class was generated from the following files: