Merge lp:~osomon/ubuntu-ui-toolkit/textfield-bubble-up-esc into lp:ubuntu-ui-toolkit/staging

Proposed by Olivier Tilloy
Status: Merged
Approved by: Cris Dywan
Approved revision: 1857
Merged at revision: 1864
Proposed branch: lp:~osomon/ubuntu-ui-toolkit/textfield-bubble-up-esc
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 106 lines (+47/-4)
3 files modified
src/Ubuntu/Components/1.3/TextArea.qml (+8/-2)
src/Ubuntu/Components/1.3/TextField.qml (+7/-1)
tests/unit_x11/tst_components/tst_textinput_common13.qml (+32/-1)
To merge this branch: bzr merge lp:~osomon/ubuntu-ui-toolkit/textfield-bubble-up-esc
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+286372@code.launchpad.net

Commit message

Bubble up ESC key press event if there is no popover to close.

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

That looks quite sensible.

Please add unit tests, probably to tests/unit_x11/tst_components/tst_textinput_common13.qml, checking that Escape is (not) caught as expected.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

> Please add unit tests, probably to
> tests/unit_x11/tst_components/tst_textinput_common13.qml, checking that
> Escape is (not) caught as expected.

Done.

Revision history for this message
Cris Dywan (kalikiana) wrote :

I love the test, elegant.

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/1.3/TextArea.qml'
2--- src/Ubuntu/Components/1.3/TextArea.qml 2016-01-13 14:25:22 +0000
3+++ src/Ubuntu/Components/1.3/TextArea.qml 2016-02-22 11:03:46 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright 2015 Canonical Ltd.
7+ * Copyright 2015-2016 Canonical Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11@@ -767,7 +767,13 @@
12 }
13
14 // Escape should close the context menu even if the menu takes no input focus
15- Keys.onEscapePressed: if (activeFocus && inputHandler.popover) PopupUtils.close(inputHandler.popover)
16+ Keys.onEscapePressed: {
17+ if (activeFocus && inputHandler.popover) {
18+ PopupUtils.close(inputHandler.popover)
19+ } else {
20+ event.accepted = false
21+ }
22+ }
23
24 LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
25 LayoutMirroring.childrenInherit: true
26
27=== modified file 'src/Ubuntu/Components/1.3/TextField.qml'
28--- src/Ubuntu/Components/1.3/TextField.qml 2016-01-26 19:46:25 +0000
29+++ src/Ubuntu/Components/1.3/TextField.qml 2016-02-22 11:03:46 +0000
30@@ -843,7 +843,13 @@
31 }
32
33 // Escape should close the context menu even if the menu takes no input focus
34- Keys.onEscapePressed: if (activeFocus && inputHandler.popover) PopupUtils.close(inputHandler.popover)
35+ Keys.onEscapePressed: {
36+ if (activeFocus && inputHandler.popover) {
37+ PopupUtils.close(inputHandler.popover)
38+ } else {
39+ event.accepted = false
40+ }
41+ }
42
43 LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
44 LayoutMirroring.childrenInherit: true
45
46=== modified file 'tests/unit_x11/tst_components/tst_textinput_common13.qml'
47--- tests/unit_x11/tst_components/tst_textinput_common13.qml 2016-01-26 12:29:24 +0000
48+++ tests/unit_x11/tst_components/tst_textinput_common13.qml 2016-02-22 11:03:46 +0000
49@@ -1,5 +1,5 @@
50 /*
51- * Copyright 2014-2015 Canonical Ltd.
52+ * Copyright 2014-2016 Canonical Ltd.
53 *
54 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU Lesser General Public License as published by
56@@ -167,6 +167,10 @@
57 id: scrollerSpy
58 signalName: "movementEnded"
59 }
60+ SignalSpy {
61+ id: escapePressedSpy
62+ signalName: "escapePressed"
63+ }
64
65 UbuntuTestCase {
66 name: "TextInputCommonTest13"
67@@ -193,6 +197,7 @@
68 movementYSpy.clear();
69 cursorRectSpy.clear();
70 scrollerSpy.clear();
71+ escapePressedSpy.clear();
72 }
73
74 function test_context_menu_items_data() {
75@@ -512,5 +517,31 @@
76 waitForRendering(data.input, 500);
77 compare(textField.focus, true, 'TextField no longer focused');
78 }
79+
80+ function test_escape_key_handling_data() {
81+ return [
82+ { tag: 'textField', input: textField},
83+ { tag: 'textArea', input: textArea},
84+ ];
85+ }
86+
87+ function test_escape_key_handling(data) {
88+ escapePressedSpy.target = data.input.parent.Keys
89+ popupSpy.target = findChild(data.input, "input_handler");
90+ data.input.focus = true;
91+ var x = data.input.width / 2;
92+ var y = data.input.height / 2;
93+ mouseClick(data.input, x, y, Qt.RightButton);
94+ popupSpy.wait();
95+ var popover = findChild(testMain, "text_input_contextmenu");
96+ verify(popover, "Cannot retrieve default TextInputPopover");
97+ waitForRendering(popover);
98+
99+ keyClick(Qt.Key_Escape);
100+ compare(escapePressedSpy.count, 0);
101+
102+ keyClick(Qt.Key_Escape);
103+ compare(escapePressedSpy.count, 1);
104+ }
105 }
106 }

Subscribers

People subscribed via source and target branches