b554ae7deec2fa743dacbaa33856014d80cfd8ba
[profile/ivi/qtdeclarative.git] / src / qtquick1 / graphicsitems / qdeclarativeevents.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "QtQuick1/private/qdeclarativeevents_p_p.h"
43
44 QT_BEGIN_NAMESPACE
45
46
47 /*!
48     \qmlclass KeyEvent QDeclarative1KeyEvent
49     \inqmlmodule QtQuick 1
50     \since QtQuick 1.0
51     \ingroup qml-event-elements
52     
53     \brief The KeyEvent object provides information about a key event.
54
55     For example, the following changes the Item's state property when the Enter
56     key is pressed:
57     \qml
58 Item {
59     focus: true
60     Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
61 }
62     \endqml
63 */
64
65 /*!
66     \qmlproperty int QtQuick1::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 QtQuick1::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 QtQuick1::KeyEvent::isAutoRepeat
93
94     This property holds whether this event comes from an auto-repeating key.
95 */
96
97 /*!
98     \qmlproperty int QtQuick1::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 QtQuick1::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     \qmlproperty int QtQuick1::KeyEvent::modifiers
116
117     This property holds the keyboard modifier flags that existed immediately
118     before the event occurred.
119
120     It contains a bitwise combination of:
121     \list
122     \o Qt.NoModifier - No modifier key is pressed.
123     \o Qt.ShiftModifier - A Shift key on the keyboard is pressed.
124     \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
125     \o Qt.AltModifier - An Alt key on the keyboard is pressed.
126     \o Qt.MetaModifier - A Meta key on the keyboard is pressed.
127     \o Qt.KeypadModifier - A keypad button is pressed.
128     \endlist
129
130     For example, to react to a Shift key + Enter key combination:
131     \qml
132     Item {
133         focus: true
134         Keys.onPressed: {
135             if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier))
136                 doSomething();
137         }
138     }
139     \endqml
140 */
141
142
143 /*!
144     \qmlclass MouseEvent QDeclarative1MouseEvent
145     \inqmlmodule QtQuick 1
146     \since QtQuick 1.0
147     \ingroup qml-event-elements
148
149     \brief The MouseEvent object provides information about a mouse event.
150
151     The position of the mouse can be found via the \l x and \l y properties.
152     The button that caused the event is available via the \l button property.
153
154     \sa MouseArea
155 */
156
157 /*!
158     \internal
159     \class QDeclarative1MouseEvent
160 */
161
162 /*!
163     \qmlproperty int QtQuick1::MouseEvent::x
164     \qmlproperty int QtQuick1::MouseEvent::y
165
166     These properties hold the coordinates of the position supplied by the mouse event.
167 */
168
169
170 /*!
171     \qmlproperty bool QtQuick1::MouseEvent::accepted
172
173     Setting \a accepted to true prevents the mouse event from being
174     propagated to items below this item.
175
176     Generally, if the item acts on the mouse event then it should be accepted
177     so that items lower in the stacking order do not also respond to the same event.
178 */
179
180 /*!
181     \qmlproperty enumeration QtQuick1::MouseEvent::button
182
183     This property holds the button that caused the event.  It can be one of:
184     \list
185     \o Qt.LeftButton
186     \o Qt.RightButton
187     \o Qt.MiddleButton
188     \endlist
189 */
190
191 /*!
192     \qmlproperty bool QtQuick1::MouseEvent::wasHeld
193
194     This property is true if the mouse button has been held pressed longer the
195     threshold (800ms).
196 */
197
198 /*!
199     \qmlproperty int QtQuick1::MouseEvent::buttons
200
201     This property holds the mouse buttons pressed when the event was generated.
202     For mouse move events, this is all buttons that are pressed down. For mouse
203     press and double click events this includes the button that caused the event.
204     For mouse release events this excludes the button that caused the event.
205
206     It contains a bitwise combination of:
207     \list
208     \o Qt.LeftButton
209     \o Qt.RightButton
210     \o Qt.MiddleButton
211     \endlist
212 */
213
214 /*!
215     \qmlproperty int QtQuick1::MouseEvent::modifiers
216
217     This property holds the keyboard modifier flags that existed immediately
218     before the event occurred.
219
220     It contains a bitwise combination of:
221     \list
222     \o Qt.NoModifier - No modifier key is pressed.
223     \o Qt.ShiftModifier - A Shift key on the keyboard is pressed.
224     \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
225     \o Qt.AltModifier - An Alt key on the keyboard is pressed.
226     \o Qt.MetaModifier - A Meta key on the keyboard is pressed.
227     \o Qt.KeypadModifier - A keypad button is pressed.
228     \endlist
229
230     For example, to react to a Shift key + Left mouse button click:
231     \qml
232     MouseArea {
233         onClicked: {
234             if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ShiftModifier))
235                 doSomething();
236         }
237     }
238     \endqml
239 */
240
241
242
243 QT_END_NAMESPACE