[844] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
| 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
| 6 | **
|
---|
| 7 | ** This file is part of the QtDeclarative module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
| 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at qt-info@nokia.com.
|
---|
| 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #include "private/qdeclarativeevents_p_p.h"
|
---|
| 43 |
|
---|
| 44 | QT_BEGIN_NAMESPACE
|
---|
| 45 | /*!
|
---|
| 46 | \qmlclass KeyEvent QDeclarativeKeyEvent
|
---|
| 47 | \since 4.7
|
---|
| 48 | \ingroup qml-event-elements
|
---|
| 49 |
|
---|
| 50 | \brief The KeyEvent object provides information about a key event.
|
---|
| 51 |
|
---|
| 52 | For example, the following changes the Item's state property when the Enter
|
---|
| 53 | key is pressed:
|
---|
| 54 | \qml
|
---|
| 55 | Item {
|
---|
| 56 | focus: true
|
---|
| 57 | Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
|
---|
| 58 | }
|
---|
| 59 | \endqml
|
---|
| 60 | */
|
---|
| 61 |
|
---|
| 62 | /*!
|
---|
| 63 | \qmlproperty int KeyEvent::key
|
---|
| 64 |
|
---|
| 65 | This property holds the code of the key that was pressed or released.
|
---|
| 66 |
|
---|
| 67 | See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. These codes are
|
---|
| 68 | independent of the underlying window system. Note that this
|
---|
| 69 | function does not distinguish between capital and non-capital
|
---|
| 70 | letters, use the text() function (returning the Unicode text the
|
---|
| 71 | key generated) for this purpose.
|
---|
| 72 |
|
---|
| 73 | A value of either 0 or \l {Qt::Key_unknown}{Qt.Key_Unknown} means that the event is not
|
---|
| 74 | the result of a known key; for example, it may be the result of
|
---|
| 75 | a compose sequence, a keyboard macro, or due to key event
|
---|
| 76 | compression.
|
---|
| 77 | */
|
---|
| 78 |
|
---|
| 79 | /*!
|
---|
| 80 | \qmlproperty string KeyEvent::text
|
---|
| 81 |
|
---|
| 82 | This property holds the Unicode text that the key generated.
|
---|
| 83 | The text returned can be an empty string in cases where modifier keys,
|
---|
| 84 | such as Shift, Control, Alt, and Meta, are being pressed or released.
|
---|
| 85 | In such cases \c key will contain a valid value
|
---|
| 86 | */
|
---|
| 87 |
|
---|
| 88 | /*!
|
---|
| 89 | \qmlproperty bool KeyEvent::isAutoRepeat
|
---|
| 90 |
|
---|
| 91 | This property holds whether this event comes from an auto-repeating key.
|
---|
| 92 | */
|
---|
| 93 |
|
---|
| 94 | /*!
|
---|
| 95 | \qmlproperty int KeyEvent::count
|
---|
| 96 |
|
---|
| 97 | This property holds the number of keys involved in this event. If \l KeyEvent::text
|
---|
| 98 | is not empty, this is simply the length of the string.
|
---|
| 99 | */
|
---|
| 100 |
|
---|
| 101 | /*!
|
---|
| 102 | \qmlproperty bool KeyEvent::accepted
|
---|
| 103 |
|
---|
| 104 | Setting \a accepted to true prevents the key event from being
|
---|
| 105 | propagated to the item's parent.
|
---|
| 106 |
|
---|
| 107 | Generally, if the item acts on the key event then it should be accepted
|
---|
| 108 | so that ancestor items do not also respond to the same event.
|
---|
| 109 | */
|
---|
| 110 |
|
---|
| 111 | /*!
|
---|
| 112 | \qmlproperty int KeyEvent::modifiers
|
---|
| 113 |
|
---|
| 114 | This property holds the keyboard modifier flags that existed immediately
|
---|
| 115 | before the event occurred.
|
---|
| 116 |
|
---|
| 117 | It contains a bitwise combination of:
|
---|
| 118 | \list
|
---|
| 119 | \o Qt.NoModifier - No modifier key is pressed.
|
---|
| 120 | \o Qt.ShiftModifier - A Shift key on the keyboard is pressed.
|
---|
| 121 | \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
|
---|
| 122 | \o Qt.AltModifier - An Alt key on the keyboard is pressed.
|
---|
| 123 | \o Qt.MetaModifier - A Meta key on the keyboard is pressed.
|
---|
| 124 | \o Qt.KeypadModifier - A keypad button is pressed.
|
---|
| 125 | \endlist
|
---|
| 126 |
|
---|
| 127 | For example, to react to a Shift key + Enter key combination:
|
---|
| 128 | \qml
|
---|
| 129 | Item {
|
---|
| 130 | focus: true
|
---|
| 131 | Keys.onPressed: {
|
---|
| 132 | if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier))
|
---|
| 133 | doSomething();
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 | \endqml
|
---|
| 137 | */
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 | /*!
|
---|
| 141 | \qmlclass MouseEvent QDeclarativeMouseEvent
|
---|
| 142 | \since 4.7
|
---|
| 143 | \ingroup qml-event-elements
|
---|
| 144 |
|
---|
| 145 | \brief The MouseEvent object provides information about a mouse event.
|
---|
| 146 |
|
---|
| 147 | The position of the mouse can be found via the \l x and \l y properties.
|
---|
| 148 | The button that caused the event is available via the \l button property.
|
---|
| 149 |
|
---|
| 150 | \sa MouseArea
|
---|
| 151 | */
|
---|
| 152 |
|
---|
| 153 | /*!
|
---|
| 154 | \internal
|
---|
| 155 | \class QDeclarativeMouseEvent
|
---|
| 156 | */
|
---|
| 157 |
|
---|
| 158 | /*!
|
---|
| 159 | \qmlproperty int MouseEvent::x
|
---|
| 160 | \qmlproperty int MouseEvent::y
|
---|
| 161 |
|
---|
| 162 | These properties hold the coordinates of the position supplied by the mouse event.
|
---|
| 163 | */
|
---|
| 164 |
|
---|
| 165 |
|
---|
| 166 | /*!
|
---|
| 167 | \qmlproperty bool MouseEvent::accepted
|
---|
| 168 |
|
---|
| 169 | Setting \a accepted to true prevents the mouse event from being
|
---|
| 170 | propagated to items below this item.
|
---|
| 171 |
|
---|
| 172 | Generally, if the item acts on the mouse event then it should be accepted
|
---|
| 173 | so that items lower in the stacking order do not also respond to the same event.
|
---|
| 174 | */
|
---|
| 175 |
|
---|
| 176 | /*!
|
---|
| 177 | \qmlproperty enumeration MouseEvent::button
|
---|
| 178 |
|
---|
| 179 | This property holds the button that caused the event. It can be one of:
|
---|
| 180 | \list
|
---|
| 181 | \o Qt.LeftButton
|
---|
| 182 | \o Qt.RightButton
|
---|
| 183 | \o Qt.MiddleButton
|
---|
| 184 | \endlist
|
---|
| 185 | */
|
---|
| 186 |
|
---|
| 187 | /*!
|
---|
| 188 | \qmlproperty bool MouseEvent::wasHeld
|
---|
| 189 |
|
---|
| 190 | This property is true if the mouse button has been held pressed longer the
|
---|
| 191 | threshold (800ms).
|
---|
| 192 | */
|
---|
| 193 |
|
---|
| 194 | /*!
|
---|
| 195 | \qmlproperty int MouseEvent::buttons
|
---|
| 196 |
|
---|
| 197 | This property holds the mouse buttons pressed when the event was generated.
|
---|
| 198 | For mouse move events, this is all buttons that are pressed down. For mouse
|
---|
| 199 | press and double click events this includes the button that caused the event.
|
---|
| 200 | For mouse release events this excludes the button that caused the event.
|
---|
| 201 |
|
---|
| 202 | It contains a bitwise combination of:
|
---|
| 203 | \list
|
---|
| 204 | \o Qt.LeftButton
|
---|
| 205 | \o Qt.RightButton
|
---|
| 206 | \o Qt.MiddleButton
|
---|
| 207 | \endlist
|
---|
| 208 | */
|
---|
| 209 |
|
---|
| 210 | /*!
|
---|
| 211 | \qmlproperty int MouseEvent::modifiers
|
---|
| 212 |
|
---|
| 213 | This property holds the keyboard modifier flags that existed immediately
|
---|
| 214 | before the event occurred.
|
---|
| 215 |
|
---|
| 216 | It contains a bitwise combination of:
|
---|
| 217 | \list
|
---|
| 218 | \o Qt.NoModifier - No modifier key is pressed.
|
---|
| 219 | \o Qt.ShiftModifier - A Shift key on the keyboard is pressed.
|
---|
| 220 | \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
|
---|
| 221 | \o Qt.AltModifier - An Alt key on the keyboard is pressed.
|
---|
| 222 | \o Qt.MetaModifier - A Meta key on the keyboard is pressed.
|
---|
| 223 | \o Qt.KeypadModifier - A keypad button is pressed.
|
---|
| 224 | \endlist
|
---|
| 225 |
|
---|
| 226 | For example, to react to a Shift key + Left mouse button click:
|
---|
| 227 | \qml
|
---|
| 228 | MouseArea {
|
---|
| 229 | onClicked: {
|
---|
| 230 | if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ShiftModifier))
|
---|
| 231 | doSomething();
|
---|
| 232 | }
|
---|
| 233 | }
|
---|
| 234 | \endqml
|
---|
| 235 | */
|
---|
| 236 |
|
---|
| 237 | QT_END_NAMESPACE
|
---|