Merge lp:~zsombi/ubuntu-ui-toolkit/textinput-focus into lp:ubuntu-ui-toolkit

Proposed by Zsombor Egri
Status: Merged
Approved by: Florian Boucault
Approved revision: 428
Merged at revision: 426
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/textinput-focus
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 182 lines (+109/-2)
4 files modified
modules/Ubuntu/Components/TextArea.qml (+9/-1)
modules/Ubuntu/Components/TextField.qml (+9/-1)
tests/unit/tst_components/tst_textarea.qml (+46/-0)
tests/unit/tst_components/tst_textfield.qml (+45/-0)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/textinput-focus
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu SDK team Pending
Review via email: mp+159420@code.launchpad.net

Commit message

Workaround for TextArea and TextField removing OSK when active focus is transferred from one instance to another using focus property.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
428. By Zsombor Egri

link to LP bug added

Revision history for this message
PS Jenkins bot (ps-jenkins) 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 'modules/Ubuntu/Components/TextArea.qml'
2--- modules/Ubuntu/Components/TextArea.qml 2013-04-16 10:29:11 +0000
3+++ modules/Ubuntu/Components/TextArea.qml 2013-04-17 16:21:23 +0000
4@@ -919,7 +919,8 @@
5 // autosize handling
6 onLineCountChanged: internal.frameSize()
7
8- // virtual keyboard handling
9+ // FIXME: workaround for bug https://bugreports.qt-project.org/browse/QTBUG-30729
10+ // input panel does not get removed when no active input is active
11 activeFocusOnPress: false
12 onActiveFocusChanged: {
13 if (activeFocus) {
14@@ -928,6 +929,13 @@
15 internal.hideInputPanel();
16 }
17 }
18+ // watch inputMethod's visible change to be able to open input panel back
19+ // removed by a previous active focus being deactivated
20+ // workaround for bug https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1163371
21+ Connections {
22+ target: Qt.inputMethod
23+ onVisibleChanged: if (editor.activeFocus) internal.showInputPanel();
24+ }
25
26 // remove selection when typing starts or input method start entering text
27 onInputMethodComposingChanged: {
28
29=== modified file 'modules/Ubuntu/Components/TextField.qml'
30--- modules/Ubuntu/Components/TextField.qml 2013-03-27 08:15:42 +0000
31+++ modules/Ubuntu/Components/TextField.qml 2013-04-17 16:21:23 +0000
32@@ -617,7 +617,8 @@
33 // forward keys to the root element so it can be captured outside of it
34 Keys.forwardTo: [control]
35
36- // virtual keyboard/software input panel handling
37+ // FIXME: workaround for bug https://bugreports.qt-project.org/browse/QTBUG-30729
38+ // input panel does not get removed when no active input is active
39 activeFocusOnPress: false
40 onActiveFocusChanged: {
41 if (activeFocus) {
42@@ -626,6 +627,13 @@
43 internal.hideInputPanel();
44 }
45 }
46+ // watch inputMethod's visible change to be able to open input panel back
47+ // removed by a previous active focus being deactivated
48+ // workaround for bug https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1163371
49+ Connections {
50+ target: Qt.inputMethod
51+ onVisibleChanged: if (editor.activeFocus) internal.showInputPanel()
52+ }
53
54 // handle virtual keyboard and cursor positioning, as the MouseArea overrides
55 // those functionalities of the TextInput
56
57=== modified file 'tests/unit/tst_components/tst_textarea.qml'
58--- tests/unit/tst_components/tst_textarea.qml 2013-04-16 10:25:54 +0000
59+++ tests/unit/tst_components/tst_textarea.qml 2013-04-17 16:21:23 +0000
60@@ -58,6 +58,17 @@
61 }
62 }
63
64+ Item {
65+ TextArea {
66+ id: t1
67+ objectName: "t1"
68+ }
69+ TextArea {
70+ id: t2
71+ objectName: "t2"
72+ }
73+ }
74+
75 TestCase {
76 name: "TextAreaAPI"
77 when: windowShown
78@@ -380,6 +391,41 @@
79 tryCompare(listItemSpy, "count", 0, 100);
80 }
81
82+ function test_OneActiveFocus() {
83+ t1.focus = true;
84+ compare(t1.activeFocus, true, "T1 has activeFocus");
85+ compare(t2.activeFocus, false, "T1 has activeFocus");
86+ t2.focus = true;
87+ compare(t1.activeFocus, false, "T1 has activeFocus");
88+ compare(t2.activeFocus, true, "T1 has activeFocus");
89+ }
90+
91+ function test_OSK_ShownWhenNextTextAreaIsFocused() {
92+ // detect whether we have OSK support
93+ Qt.inputMethod.show();
94+ if (!Qt.inputMethod.visible)
95+ expectFail("", "OSK can be tested only when present");
96+ else
97+ Qt.inputMethod.hide();
98+ t1.focus = true;
99+ compare(Qt.inputMethod.visible, true, "OSK is shown for the first TextArea");
100+ t2.focus = true;
101+ compare(Qt.inputMethod.visible, true, "OSK is shown for the second TextArea");
102+ }
103+
104+ function test_RemoveOSKWhenFocusLost() {
105+ // detect whether we have OSK support
106+ Qt.inputMethod.show();
107+ if (!Qt.inputMethod.visible)
108+ expectFail("", "OSK can be tested only when present");
109+ else
110+ Qt.inputMethod.hide();
111+ t1.focus = true;
112+ compare(Qt.inputMethod.visible, true, "OSK is shown when TextArea gains focus");
113+ t1.focus = false;
114+ compare(Qt.inputMethod.visible, false, "OSK is hidden when TextArea looses focus");
115+ }
116+
117 // make it to b ethe last test case executed
118 function test_zz_TextareaInListItem_RichTextEnterCaptured() {
119 textArea.text = "a<br />b";
120
121=== modified file 'tests/unit/tst_components/tst_textfield.qml'
122--- tests/unit/tst_components/tst_textfield.qml 2013-02-13 10:52:46 +0000
123+++ tests/unit/tst_components/tst_textfield.qml 2013-04-17 16:21:23 +0000
124@@ -38,6 +38,15 @@
125 Keys.onReleased: keyReleaseData = event.key
126 }
127
128+ Item {
129+ TextField {
130+ id: t1
131+ }
132+ TextField {
133+ id: t2
134+ }
135+ }
136+
137 function initTestCase() {
138 textField.forceActiveFocus();
139 compare(textField.focus, true, "TextField is focused");
140@@ -195,6 +204,42 @@
141 compare(textField.text, "test text", "Data pasted");
142 }
143
144+ function test_OneActiveFocus() {
145+ t1.focus = true;
146+ compare(t1.activeFocus, true, "T1 has activeFocus");
147+ compare(t2.activeFocus, false, "T1 has activeFocus");
148+ t2.focus = true;
149+ compare(t1.activeFocus, false, "T1 has activeFocus");
150+ compare(t2.activeFocus, true, "T1 has activeFocus");
151+ }
152+
153+ // need to make the very first test case, otherwise OSK detection fails on phablet
154+ function test_00_OSK_ShownWhenNextTextFieldIsFocused() {
155+ // detect whether we have OSK support
156+ Qt.inputMethod.show();
157+ if (!Qt.inputMethod.visible)
158+ expectFail("", "OSK can be tested only when present");
159+ else
160+ Qt.inputMethod.hide();
161+ t1.focus = true;
162+ compare(Qt.inputMethod.visible, true, "OSK is shown for the first TextField");
163+ t2.focus = true;
164+ compare(Qt.inputMethod.visible, true, "OSK is shown for the second TextField");
165+ }
166+
167+ function test_RemoveOSKWhenFocusLost() {
168+ // detect whether we have OSK support
169+ Qt.inputMethod.show();
170+ if (!Qt.inputMethod.visible)
171+ expectFail("", "OSK can be tested only when present");
172+ else
173+ Qt.inputMethod.hide();
174+ t1.focus = true;
175+ compare(Qt.inputMethod.visible, true, "OSK is shown when TextField gains focus");
176+ t1.focus = false;
177+ compare(Qt.inputMethod.visible, false, "OSK is hidden when TextField looses focus");
178+ }
179+
180 RegExpValidator {
181 id: regExpValidator
182 regExp: /[a-z]*/

Subscribers

People subscribed via source and target branches

to status/vote changes: