Change copyrights from Nokia to Digia
[profile/ivi/qtdeclarative.git] / src / quick / items / qquickevents.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "qquickevents_p_p.h"
43
44 QT_BEGIN_NAMESPACE
45
46 /*!
47     \qmltype KeyEvent
48     \instantiates QQuickKeyEvent
49     \inqmlmodule QtQuick 2
50     \ingroup qtquick-input-events
51
52     \brief Provides information about a key event
53
54     For example, the following changes the Item's state property when the Enter
55     key is pressed:
56     \qml
57 Item {
58     focus: true
59     Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
60 }
61     \endqml
62 */
63
64 /*!
65     \qmlproperty int QtQuick2::KeyEvent::key
66
67     This property holds the code of the key that was pressed or released.
68
69     See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. These codes are
70     independent of the underlying window system. Note that this
71     function does not distinguish between capital and non-capital
72     letters, use the text() function (returning the Unicode text the
73     key generated) for this purpose.
74
75     A value of either 0 or \l {Qt::Key_unknown}{Qt.Key_Unknown} means that the event is not
76     the result of a known key; for example, it may be the result of
77     a compose sequence, a keyboard macro, or due to key event
78     compression.
79 */
80
81 /*!
82     \qmlproperty string QtQuick2::KeyEvent::text
83
84     This property holds the Unicode text that the key generated.
85     The text returned can be an empty string in cases where modifier keys,
86     such as Shift, Control, Alt, and Meta, are being pressed or released.
87     In such cases \c key will contain a valid value
88 */
89
90 /*!
91     \qmlproperty bool QtQuick2::KeyEvent::isAutoRepeat
92
93     This property holds whether this event comes from an auto-repeating key.
94 */
95
96 /*!
97     \qmlproperty quint32 QtQuick2::KeyEvent::nativeScanCode
98
99     This property contains the native scan code of the key that was pressed. It is
100     passed through from QKeyEvent unchanged.
101
102     \sa QKeyEvent::nativeScanCode()
103 */
104
105 /*!
106     \qmlproperty int QtQuick2::KeyEvent::count
107
108     This property holds the number of keys involved in this event. If \l KeyEvent::text
109     is not empty, this is simply the length of the string.
110 */
111
112 /*!
113     \qmlproperty bool QtQuick2::KeyEvent::accepted
114
115     Setting \a accepted to true prevents the key event from being
116     propagated to the item's parent.
117
118     Generally, if the item acts on the key event then it should be accepted
119     so that ancestor items do not also respond to the same event.
120 */
121
122 /*!
123     \qmlproperty int QtQuick2::KeyEvent::modifiers
124
125     This property holds the keyboard modifier flags that existed immediately
126     before the event occurred.
127
128     It contains a bitwise combination of:
129     \list
130     \li Qt.NoModifier - No modifier key is pressed.
131     \li Qt.ShiftModifier - A Shift key on the keyboard is pressed.
132     \li Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
133     \li Qt.AltModifier - An Alt key on the keyboard is pressed.
134     \li Qt.MetaModifier - A Meta key on the keyboard is pressed.
135     \li Qt.KeypadModifier - A keypad button is pressed.
136     \endlist
137
138     For example, to react to a Shift key + Enter key combination:
139     \qml
140     Item {
141         focus: true
142         Keys.onPressed: {
143             if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier))
144                 doSomething();
145         }
146     }
147     \endqml
148 */
149
150
151 /*!
152     \qmltype MouseEvent
153     \instantiates QQuickMouseEvent
154     \inqmlmodule QtQuick 2
155     \ingroup qtquick-input-events
156
157     \brief Provides information about a mouse event
158
159     The position of the mouse can be found via the \l x and \l y properties.
160     The button that caused the event is available via the \l button property.
161
162     \sa MouseArea
163 */
164
165 /*!
166     \internal
167     \class QQuickMouseEvent
168 */
169
170 /*!
171     \qmlproperty int QtQuick2::MouseEvent::x
172     \qmlproperty int QtQuick2::MouseEvent::y
173
174     These properties hold the coordinates of the position supplied by the mouse event.
175 */
176
177
178 /*!
179     \qmlproperty bool QtQuick2::MouseEvent::accepted
180
181     Setting \a accepted to true prevents the mouse event from being
182     propagated to items below this item.
183
184     Generally, if the item acts on the mouse event then it should be accepted
185     so that items lower in the stacking order do not also respond to the same event.
186 */
187
188 /*!
189     \qmlproperty enumeration QtQuick2::MouseEvent::button
190
191     This property holds the button that caused the event.  It can be one of:
192     \list
193     \li Qt.LeftButton
194     \li Qt.RightButton
195     \li Qt.MiddleButton
196     \endlist
197 */
198
199 /*!
200     \qmlproperty bool QtQuick2::MouseEvent::wasHeld
201
202     This property is true if the mouse button has been held pressed longer the
203     threshold (800ms).
204 */
205
206 /*!
207     \qmlproperty int QtQuick2::MouseEvent::buttons
208
209     This property holds the mouse buttons pressed when the event was generated.
210     For mouse move events, this is all buttons that are pressed down. For mouse
211     press and double click events this includes the button that caused the event.
212     For mouse release events this excludes the button that caused the event.
213
214     It contains a bitwise combination of:
215     \list
216     \li Qt.LeftButton
217     \li Qt.RightButton
218     \li Qt.MiddleButton
219     \endlist
220 */
221
222 /*!
223     \qmlproperty int QtQuick2::MouseEvent::modifiers
224
225     This property holds the keyboard modifier flags that existed immediately
226     before the event occurred.
227
228     It contains a bitwise combination of:
229     \list
230     \li Qt.NoModifier - No modifier key is pressed.
231     \li Qt.ShiftModifier - A Shift key on the keyboard is pressed.
232     \li Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
233     \li Qt.AltModifier - An Alt key on the keyboard is pressed.
234     \li Qt.MetaModifier - A Meta key on the keyboard is pressed.
235     \li Qt.KeypadModifier - A keypad button is pressed.
236     \endlist
237
238     For example, to react to a Shift key + Left mouse button click:
239     \qml
240     MouseArea {
241         onClicked: {
242             if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ShiftModifier))
243                 doSomething();
244         }
245     }
246     \endqml
247 */
248
249
250 /*!
251     \qmltype WheelEvent
252     \instantiates QQuickWheelEvent
253     \inqmlmodule QtQuick 2
254     \ingroup qtquick-input-events
255     \brief Provides information about a mouse wheel event
256
257     The position of the mouse can be found via the \l x and \l y properties.
258
259     \sa MouseArea
260 */
261
262 /*!
263     \internal
264     \class QQuickWheelEvent
265 */
266
267 /*!
268     \qmlproperty int QtQuick2::WheelEvent::x
269     \qmlproperty int QtQuick2::WheelEvent::y
270
271     These properties hold the coordinates of the position supplied by the wheel event.
272 */
273
274 /*!
275     \qmlproperty bool QtQuick2::WheelEvent::accepted
276
277     Setting \a accepted to true prevents the wheel event from being
278     propagated to items below this item.
279
280     Generally, if the item acts on the wheel event then it should be accepted
281     so that items lower in the stacking order do not also respond to the same event.
282 */
283
284 /*!
285     \qmlproperty int QtQuick2::WheelEvent::buttons
286
287     This property holds the mouse buttons pressed when the wheel event was generated.
288
289     It contains a bitwise combination of:
290     \list
291     \li Qt.LeftButton
292     \li Qt.RightButton
293     \li Qt.MiddleButton
294     \endlist
295 */
296
297 /*!
298     \qmlproperty point QtQuick2::WheelEvent::angleDelta
299
300     This property holds the distance that the wheel is rotated in wheel degrees.
301     The x and y cordinate of this property holds the delta in horizontal and
302     vertical orientation.
303
304     A positive value indicates that the wheel was rotated up/right;
305     a negative value indicates that the wheel was rotated down/left.
306
307     Most mouse types work in steps of 15 degrees, in which case the delta value is a
308     multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
309 */
310
311 /*!
312     \qmlproperty point QtQuick2::WheelEvent::pixelDelta
313
314     This property holds the delta in screen pixels and is available in plataforms that
315     have high-resolution trackpads, such as Mac OS X.
316     The x and y cordinate of this property holds the delta in horizontal and
317     vertical orientation. The value should be used directly to scroll content on screen.
318
319     For platforms without high-resolution trackpad support, pixelDelta will always be (0,0),
320     and angleDelta should be used instead.
321 */
322
323 /*!
324     \qmlproperty int QtQuick2::WheelEvent::modifiers
325
326     This property holds the keyboard modifier flags that existed immediately
327     before the event occurred.
328
329     It contains a bitwise combination of:
330     \list
331     \li Qt.NoModifier - No modifier key is pressed.
332     \li Qt.ShiftModifier - A Shift key on the keyboard is pressed.
333     \li Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
334     \li Qt.AltModifier - An Alt key on the keyboard is pressed.
335     \li Qt.MetaModifier - A Meta key on the keyboard is pressed.
336     \li Qt.KeypadModifier - A keypad button is pressed.
337     \endlist
338
339     For example, to react to a Control key pressed during the wheel event:
340     \qml
341     MouseArea {
342         onWheel: {
343             if (wheel.modifiers & Qt.ControlModifier) {
344                 if (wheel.angleDelta.y > 0)
345                     zoomIn();
346                 else
347                     zoomOut();
348             }
349         }
350     }
351     \endqml
352 */
353
354 QT_END_NAMESPACE