summaryrefslogtreecommitdiff
path: root/tests/auto/controls/data/textfield
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@digia.com>2014-01-21 13:07:21 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-22 16:09:31 +0100
commit5dc805c86077ee9cd10af530f802fdda879cfb6a (patch)
tree44a13a83b6e79d0e81420b2167eaf20b018f01c6 /tests/auto/controls/data/textfield
parent5e022a65531b92d4d2f4cf9a0dd6b843aadf3797 (diff)
downloadqtquickcontrols-5dc805c86077ee9cd10af530f802fdda879cfb6a.tar.gz
Controls: Fixed support for Keys attached property on controls allowing text input
By forwarding key events from the internal control. It includes TextField, TextArea, ComboBox, SpinBox. The key events from internal are Keys.forwardTo controls, then user could customize their own behavior for those controls. Autotest are included. [ChangeLog][QtQuickControls] Fixed support for Keys attached property on controls allowing text input, by forwarding key events from the internal control. Task-number: QTBUG-33493 Task-number: QTBUG-34101 Task-number: QTBUG-35763 Change-Id: I00ea131160e55048b34fe0713e1ee02ff9472f05 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'tests/auto/controls/data/textfield')
-rw-r--r--tests/auto/controls/data/textfield/tf_keys.qml62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/controls/data/textfield/tf_keys.qml b/tests/auto/controls/data/textfield/tf_keys.qml
new file mode 100644
index 00000000..4124651d
--- /dev/null
+++ b/tests/auto/controls/data/textfield/tf_keys.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Controls 1.1
+
+Row {
+ width: 100
+ height: 50
+ spacing: 10
+
+ property alias control1: _control1
+ TextField {
+ id: _control1
+ text: ""
+ property bool gotit: false
+ Keys.onPressed: {
+ if ((!gotit) && (event.key === Qt.Key_B)) {
+ gotit = true;
+ event.accepted = true;
+ return;
+ }
+ }
+ }
+}