From 3b5354386225974ea6db78c12f32cb81e2d50104 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 17 Aug 2011 13:14:57 +0200 Subject: Add a QApplication::queryKeyboardModifiers() method. QApplication::keyboardModifiers returns the keyboard modifiers from the last keypress event in this process, as documented. However there are use cases for querying keyboard modifiers as they currently are, see QTBUG-11243. Merge-request: 585 Reviewed-by: Frederik Gladhorn --- src/gui/kernel/qapplication.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/gui/kernel/qapplication.cpp') diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index cd13894609..15d37c3c08 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -3321,7 +3321,7 @@ bool QApplication::desktopSettingsAware() one of the above events. If no keys are being held Qt::NoModifier is returned. - \sa mouseButtons() + \sa mouseButtons(), queryKeyboardModifiers() */ Qt::KeyboardModifiers QApplication::keyboardModifiers() @@ -3329,6 +3329,25 @@ Qt::KeyboardModifiers QApplication::keyboardModifiers() return QApplicationPrivate::modifier_buttons; } +/*! + \fn Qt::KeyboardModifiers QApplication::queryKeyboardModifiers() + + Queries and returns the state of the modifier keys on the keyboard. + Unlike keyboardModifiers, this method returns the actual keys held + on the input device at the time of calling the method. + + It does not rely on the keypress events having been received by this + process, which makes it possible to check the modifiers while moving + a window, for instance. Note that in most cases, you should use + keyboardModifiers(), which is faster and more accurate since it contains + the state of the modifiers as they were when the currently processed + event was received. + + \sa keyboardModifiers() + + \since 4.8 +*/ + /*! Returns the current state of the buttons on the mouse. The current state is updated syncronously as the event queue is emptied of events that will -- cgit v1.2.3