|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 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 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
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 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
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 \brief The KeyEvent object provides information about a key event. |
|
49 |
|
50 For example, the following changes the Item's state property when the Enter |
|
51 key is pressed: |
|
52 \qml |
|
53 Item { |
|
54 focus: true |
|
55 Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; } |
|
56 } |
|
57 \endqml |
|
58 */ |
|
59 |
|
60 /*! |
|
61 \internal |
|
62 \class QDeclarativeKeyEvent |
|
63 */ |
|
64 |
|
65 /*! |
|
66 \qmlproperty int KeyEvent::key |
|
67 |
|
68 This property holds the code of the key that was pressed or released. |
|
69 |
|
70 See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. These codes are |
|
71 independent of the underlying window system. Note that this |
|
72 function does not distinguish between capital and non-capital |
|
73 letters, use the text() function (returning the Unicode text the |
|
74 key generated) for this purpose. |
|
75 |
|
76 A value of either 0 or \l {Qt::Key_unknown}{Qt.Key_Unknown} means that the event is not |
|
77 the result of a known key; for example, it may be the result of |
|
78 a compose sequence, a keyboard macro, or due to key event |
|
79 compression. |
|
80 */ |
|
81 |
|
82 /*! |
|
83 \qmlproperty string KeyEvent::text |
|
84 |
|
85 This property holds the Unicode text that the key generated. |
|
86 The text returned can be an empty string in cases where modifier keys, |
|
87 such as Shift, Control, Alt, and Meta, are being pressed or released. |
|
88 In such cases \c key will contain a valid value |
|
89 */ |
|
90 |
|
91 /*! |
|
92 \qmlproperty bool KeyEvent::isAutoRepeat |
|
93 |
|
94 This property holds whether this event comes from an auto-repeating key. |
|
95 */ |
|
96 |
|
97 /*! |
|
98 \qmlproperty int KeyEvent::count |
|
99 |
|
100 This property holds the number of keys involved in this event. If \l KeyEvent::text |
|
101 is not empty, this is simply the length of the string. |
|
102 */ |
|
103 |
|
104 /*! |
|
105 \qmlproperty bool KeyEvent::accepted |
|
106 |
|
107 Setting \a accepted to true prevents the key event from being |
|
108 propagated to the item's parent. |
|
109 |
|
110 Generally, if the item acts on the key event then it should be accepted |
|
111 so that ancestor items do not also respond to the same event. |
|
112 */ |
|
113 |
|
114 |
|
115 /*! |
|
116 \qmlclass MouseEvent QDeclarativeMouseEvent |
|
117 \since 4.7 |
|
118 \brief The MouseEvent object provides information about a mouse event. |
|
119 |
|
120 The position of the mouse can be found via the x and y properties. |
|
121 The button that caused the event is available via the button property. |
|
122 */ |
|
123 |
|
124 /*! |
|
125 \internal |
|
126 \class QDeclarativeMouseEvent |
|
127 */ |
|
128 |
|
129 /*! |
|
130 \qmlproperty int MouseEvent::x |
|
131 \qmlproperty int MouseEvent::y |
|
132 |
|
133 These properties hold the position of the mouse event. |
|
134 */ |
|
135 |
|
136 |
|
137 /*! |
|
138 \qmlproperty bool MouseEvent::accepted |
|
139 |
|
140 Setting \a accepted to true prevents the mouse event from being |
|
141 propagated to items below this item. |
|
142 |
|
143 Generally, if the item acts on the mouse event then it should be accepted |
|
144 so that items lower in the stacking order do not also respond to the same event. |
|
145 */ |
|
146 |
|
147 /*! |
|
148 \qmlproperty enumeration MouseEvent::button |
|
149 |
|
150 This property holds the button that caused the event. It can be one of: |
|
151 \list |
|
152 \o Qt.LeftButton |
|
153 \o Qt.RightButton |
|
154 \o Qt.MiddleButton |
|
155 \endlist |
|
156 */ |
|
157 |
|
158 /*! |
|
159 \qmlproperty bool MouseEvent::wasHeld |
|
160 |
|
161 This property is true if the mouse button has been held pressed longer the |
|
162 threshold (800ms). |
|
163 */ |
|
164 |
|
165 /*! |
|
166 \qmlproperty int MouseEvent::buttons |
|
167 |
|
168 This property holds the mouse buttons pressed when the event was generated. |
|
169 For mouse move events, this is all buttons that are pressed down. For mouse |
|
170 press and double click events this includes the button that caused the event. |
|
171 For mouse release events this excludes the button that caused the event. |
|
172 |
|
173 It contains a bitwise combination of: |
|
174 \list |
|
175 \o Qt.LeftButton |
|
176 \o Qt.RightButton |
|
177 \o Qt.MiddleButton |
|
178 \endlist |
|
179 */ |
|
180 |
|
181 /*! |
|
182 \qmlproperty int MouseEvent::modifiers |
|
183 |
|
184 This property holds the keyboard modifier flags that existed immediately |
|
185 before the event occurred. |
|
186 |
|
187 It contains a bitwise combination of: |
|
188 \list |
|
189 \o Qt.NoModifier - No modifier key is pressed. |
|
190 \o Qt.ShiftModifier - A Shift key on the keyboard is pressed. |
|
191 \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed. |
|
192 \o Qt.AltModifier - An Alt key on the keyboard is pressed. |
|
193 \o Qt.MetaModifier - A Meta key on the keyboard is pressed. |
|
194 \o Qt.KeypadModifier - A keypad button is pressed. |
|
195 \endlist |
|
196 |
|
197 For example, to react to a Shift key + Left mouse button click: |
|
198 \qml |
|
199 MouseArea { |
|
200 onClicked: { if (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier) doSomething(); } |
|
201 } |
|
202 \endqml |
|
203 */ |
|
204 |
|
205 QT_END_NAMESPACE |