1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
42 #include "QtQuick1/private/qdeclarativeevents_p_p.h"
48 \qmlclass KeyEvent QDeclarative1KeyEvent
49 \inqmlmodule QtQuick 1
51 \ingroup qml-event-elements
53 \brief The KeyEvent object provides information about a key event.
55 For example, the following changes the Item's state property when the Enter
60 Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
66 \qmlproperty int QtQuick1::KeyEvent::key
68 This property holds the code of the key that was pressed or released.
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.
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
83 \qmlproperty string QtQuick1::KeyEvent::text
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
92 \qmlproperty bool QtQuick1::KeyEvent::isAutoRepeat
94 This property holds whether this event comes from an auto-repeating key.
98 \qmlproperty int QtQuick1::KeyEvent::count
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.
105 \qmlproperty bool QtQuick1::KeyEvent::accepted
107 Setting \a accepted to true prevents the key event from being
108 propagated to the item's parent.
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.
115 \qmlproperty int QtQuick1::KeyEvent::modifiers
117 This property holds the keyboard modifier flags that existed immediately
118 before the event occurred.
120 It contains a bitwise combination of:
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.
130 For example, to react to a Shift key + Enter key combination:
135 if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier))
144 \qmlclass MouseEvent QDeclarative1MouseEvent
145 \inqmlmodule QtQuick 1
147 \ingroup qml-event-elements
149 \brief The MouseEvent object provides information about a mouse event.
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.
159 \class QDeclarative1MouseEvent
163 \qmlproperty int QtQuick1::MouseEvent::x
164 \qmlproperty int QtQuick1::MouseEvent::y
166 These properties hold the coordinates of the position supplied by the mouse event.
171 \qmlproperty bool QtQuick1::MouseEvent::accepted
173 Setting \a accepted to true prevents the mouse event from being
174 propagated to items below this item.
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.
181 \qmlproperty enumeration QtQuick1::MouseEvent::button
183 This property holds the button that caused the event. It can be one of:
192 \qmlproperty bool QtQuick1::MouseEvent::wasHeld
194 This property is true if the mouse button has been held pressed longer the
199 \qmlproperty int QtQuick1::MouseEvent::buttons
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.
206 It contains a bitwise combination of:
215 \qmlproperty int QtQuick1::MouseEvent::modifiers
217 This property holds the keyboard modifier flags that existed immediately
218 before the event occurred.
220 It contains a bitwise combination of:
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.
230 For example, to react to a Shift key + Left mouse button click:
234 if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ShiftModifier))