Merge lp:~zsombi/ubuntu-ui-toolkit/textfield-api into lp:ubuntu-ui-toolkit
- textfield-api
- Merge into trunk
Proposed by
Zsombor Egri
Status: | Merged |
---|---|
Approved by: | Tim Peeters |
Approved revision: | 578 |
Merged at revision: | 576 |
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/textfield-api |
Merge into: | lp:ubuntu-ui-toolkit |
Diff against target: |
963 lines (+519/-73) 3 files modified
components.api (+27/-2) modules/Ubuntu/Components/TextField.qml (+343/-70) tests/unit_x11/tst_components/tst_textfield.qml (+149/-1) |
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/textfield-api |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Tim Peeters | Pending | ||
Review via email: mp+172781@code.launchpad.net |
Commit message
TextField API extended with API left out from TextInput. wrapMode is not inlcuded as does not make sense to be used in single line input.
Description of the change
To post a comment you must log in.
- 578. By Zsombor Egri
-
forceActiveFocus moved back to internal
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 'components.api' | |||
2 | --- components.api 2013-07-02 00:19:41 +0000 | |||
3 | +++ components.api 2013-07-03 10:36:26 +0000 | |||
4 | @@ -255,22 +255,40 @@ | |||
5 | 255 | property alias secondaryItem | 255 | property alias secondaryItem |
6 | 256 | property bool errorHighlight | 256 | property bool errorHighlight |
7 | 257 | property alias acceptableInput | 257 | property alias acceptableInput |
8 | 258 | property alias activeFocusOnPress | ||
9 | 259 | property alias autoScroll | ||
10 | 260 | property alias canPaste | ||
11 | 261 | property alias canRedo | ||
12 | 262 | property alias canUndo | ||
13 | 263 | property alias color | ||
14 | 264 | property alias contentHeight | ||
15 | 265 | property alias contentWidth | ||
16 | 266 | property alias cursorDelegate | ||
17 | 258 | property alias cursorPosition | 267 | property alias cursorPosition |
18 | 268 | property alias cursorRectangle | ||
19 | 269 | property alias cursorVisible | ||
20 | 270 | property alias displayText | ||
21 | 259 | property alias echoMode | 271 | property alias echoMode |
22 | 260 | property alias font | 272 | property alias font |
23 | 261 | property alias inputMask | 273 | property alias inputMask |
24 | 262 | property alias inputMethodComposing | 274 | property alias inputMethodComposing |
25 | 263 | property alias inputMethodHints | 275 | property alias inputMethodHints |
26 | 276 | property alias length | ||
27 | 264 | property alias maximumLength | 277 | property alias maximumLength |
28 | 278 | property alias mouseSelectionMode | ||
29 | 279 | property alias persistentSelection | ||
30 | 265 | property alias readOnly | 280 | property alias readOnly |
32 | 266 | property alias selectedText | 281 | property alias renderType |
33 | 282 | property alias selectByMouse | ||
34 | 283 | readonly property alias selectedText | ||
35 | 267 | property alias selectionStart | 284 | property alias selectionStart |
36 | 268 | property alias selectionEnd | 285 | property alias selectionEnd |
37 | 269 | property alias text | 286 | property alias text |
38 | 270 | property alias validator | 287 | property alias validator |
39 | 271 | property alias horizontalAlignment | 288 | property alias horizontalAlignment |
40 | 289 | property alias effectiveHorizontalAlignment | ||
41 | 290 | property alias verticalAlignment | ||
42 | 272 | property alias passwordCharacter | 291 | property alias passwordCharacter |
43 | 273 | property alias color | ||
44 | 274 | property alias selectionColor | 292 | property alias selectionColor |
45 | 275 | property alias selectedTextColor | 293 | property alias selectedTextColor |
46 | 276 | signal accepted() | 294 | signal accepted() |
47 | @@ -278,12 +296,19 @@ | |||
48 | 278 | function cut() | 296 | function cut() |
49 | 279 | function paste(data) | 297 | function paste(data) |
50 | 280 | function deselect() | 298 | function deselect() |
51 | 299 | function insert(position, text) | ||
52 | 281 | function positionAt(x, position) | 300 | function positionAt(x, position) |
53 | 282 | function positionToRectangle(pos) | 301 | function positionToRectangle(pos) |
54 | 283 | function select(start, end) | 302 | function select(start, end) |
55 | 284 | function selectAll() | 303 | function selectAll() |
56 | 285 | function selectWord() | 304 | function selectWord() |
57 | 286 | function forceActiveFocus() | 305 | function forceActiveFocus() |
58 | 306 | function isRightToLeft(start, end) | ||
59 | 307 | function moveCursorSelection(position, mode) | ||
60 | 308 | function redo() | ||
61 | 309 | function undo() | ||
62 | 310 | function remove(start, end) | ||
63 | 311 | function getText(start, end) | ||
64 | 287 | property alias __internal | 312 | property alias __internal |
65 | 288 | modules/Ubuntu/Components/TextInputPopover.qml | 313 | modules/Ubuntu/Components/TextInputPopover.qml |
66 | 289 | ActionSelectionPopover | 314 | ActionSelectionPopover |
67 | 290 | 315 | ||
68 | === modified file 'modules/Ubuntu/Components/TextField.qml' | |||
69 | --- modules/Ubuntu/Components/TextField.qml 2013-06-27 15:20:12 +0000 | |||
70 | +++ modules/Ubuntu/Components/TextField.qml 2013-07-03 10:36:26 +0000 | |||
71 | @@ -85,7 +85,6 @@ | |||
72 | 85 | property bool highlighted: focus | 85 | property bool highlighted: focus |
73 | 86 | 86 | ||
74 | 87 | /*! | 87 | /*! |
75 | 88 | \preliminary | ||
76 | 89 | Text that appears when there is no focus and no content in the component. | 88 | Text that appears when there is no focus and no content in the component. |
77 | 90 | 89 | ||
78 | 91 | \qmlproperty string placeholderText | 90 | \qmlproperty string placeholderText |
79 | @@ -93,7 +92,6 @@ | |||
80 | 93 | property alias placeholderText: hint.text | 92 | property alias placeholderText: hint.text |
81 | 94 | 93 | ||
82 | 95 | /*! | 94 | /*! |
83 | 96 | \preliminary | ||
84 | 97 | Specifies whether the control has a clear button or not. | 95 | Specifies whether the control has a clear button or not. |
85 | 98 | */ | 96 | */ |
86 | 99 | property bool hasClearButton: true | 97 | property bool hasClearButton: true |
87 | @@ -112,7 +110,6 @@ | |||
88 | 112 | property var popover | 110 | property var popover |
89 | 113 | 111 | ||
90 | 114 | /*! | 112 | /*! |
91 | 115 | \preliminary | ||
92 | 116 | Overlaid component that can be set for the fore side of the TextField, | 113 | Overlaid component that can be set for the fore side of the TextField, |
93 | 117 | e.g.showing a magnifier to implement search functionality. | 114 | e.g.showing a magnifier to implement search functionality. |
94 | 118 | 115 | ||
95 | @@ -121,7 +118,6 @@ | |||
96 | 121 | property alias primaryItem: leftPane.data | 118 | property alias primaryItem: leftPane.data |
97 | 122 | 119 | ||
98 | 123 | /*! | 120 | /*! |
99 | 124 | \preliminary | ||
100 | 125 | Overlaid component that can be set for the rear side of the TextField, | 121 | Overlaid component that can be set for the rear side of the TextField, |
101 | 126 | e.g.showing a CAPS LOCK or NUM LOCK indication. The overlaid components | 122 | e.g.showing a CAPS LOCK or NUM LOCK indication. The overlaid components |
102 | 127 | will be placed right after the clear button. | 123 | will be placed right after the clear button. |
103 | @@ -131,14 +127,12 @@ | |||
104 | 131 | property alias secondaryItem: rightPane.data | 127 | property alias secondaryItem: rightPane.data |
105 | 132 | 128 | ||
106 | 133 | /*! | 129 | /*! |
107 | 134 | \preliminary | ||
108 | 135 | Allows highlighting errors in the TextField. | 130 | Allows highlighting errors in the TextField. |
109 | 136 | */ | 131 | */ |
110 | 137 | property bool errorHighlight: !acceptableInput | 132 | property bool errorHighlight: !acceptableInput |
111 | 138 | 133 | ||
112 | 139 | // aliased properties from TextInput | 134 | // aliased properties from TextInput |
113 | 140 | /*! | 135 | /*! |
114 | 141 | \preliminary | ||
115 | 142 | This property is always true unless a validator or input mask has been set. | 136 | This property is always true unless a validator or input mask has been set. |
116 | 143 | If a validator or input mask has been set, this property will only be true | 137 | If a validator or input mask has been set, this property will only be true |
117 | 144 | if the current text is acceptable to the validator or input mask as a final | 138 | if the current text is acceptable to the validator or input mask as a final |
118 | @@ -149,7 +143,84 @@ | |||
119 | 149 | property alias acceptableInput: editor.acceptableInput | 143 | property alias acceptableInput: editor.acceptableInput |
120 | 150 | 144 | ||
121 | 151 | /*! | 145 | /*! |
123 | 152 | \preliminary | 146 | Whether the TextField should gain active focus on a mouse press. By default |
124 | 147 | this is set to true. | ||
125 | 148 | |||
126 | 149 | \qmlproperty bool activeFocusOnPress | ||
127 | 150 | */ | ||
128 | 151 | property alias activeFocusOnPress: editor.activeFocusOnPress | ||
129 | 152 | |||
130 | 153 | /*! | ||
131 | 154 | Whether the TextField should scroll when the text is longer than the width. | ||
132 | 155 | By default this is set to true. | ||
133 | 156 | |||
134 | 157 | \qmlproperty bool autoScroll | ||
135 | 158 | */ | ||
136 | 159 | property alias autoScroll: editor.autoScroll | ||
137 | 160 | |||
138 | 161 | /*! | ||
139 | 162 | Returns true if the TextField is writable and the content of the clipboard | ||
140 | 163 | is suitable for pasting into the TextField. | ||
141 | 164 | |||
142 | 165 | \qmlproperty bool canPaste | ||
143 | 166 | */ | ||
144 | 167 | property alias canPaste: editor.canPaste | ||
145 | 168 | |||
146 | 169 | /*! | ||
147 | 170 | Returns true if the TextField is writable and there are undone operations | ||
148 | 171 | that can be redone. | ||
149 | 172 | |||
150 | 173 | \qmlproperty bool canRedo | ||
151 | 174 | */ | ||
152 | 175 | property alias canRedo: editor.canRedo | ||
153 | 176 | |||
154 | 177 | /*! | ||
155 | 178 | Returns true if the TextField is writable and there are previous operations | ||
156 | 179 | that can be undone. | ||
157 | 180 | |||
158 | 181 | \qmlproperty bool canUndo | ||
159 | 182 | */ | ||
160 | 183 | property alias canUndo: editor.canUndo | ||
161 | 184 | |||
162 | 185 | /*! | ||
163 | 186 | The text color. | ||
164 | 187 | \qmlproperty color color | ||
165 | 188 | */ | ||
166 | 189 | property alias color: editor.color | ||
167 | 190 | |||
168 | 191 | /*! | ||
169 | 192 | Returns the height of the text, including the height past the height that | ||
170 | 193 | is covered if the text does not fit within the set height. | ||
171 | 194 | |||
172 | 195 | \qmlproperty real contentHeight | ||
173 | 196 | */ | ||
174 | 197 | property alias contentHeight: editor.contentHeight | ||
175 | 198 | |||
176 | 199 | /*! | ||
177 | 200 | Returns the width of the text, including the width past the width which | ||
178 | 201 | is covered due to insufficient wrapping if wrapMode is set. | ||
179 | 202 | |||
180 | 203 | \qmlproperty real contentWidth | ||
181 | 204 | */ | ||
182 | 205 | property alias contentWidth: editor.contentWidth | ||
183 | 206 | |||
184 | 207 | /*! | ||
185 | 208 | The delegate for the cursor in the TextField. | ||
186 | 209 | |||
187 | 210 | If you set a cursorDelegate for a TextField, this delegate will be used for | ||
188 | 211 | drawing the cursor instead of the standard cursor. An instance of the delegate | ||
189 | 212 | will be created and managed by the TextField when a cursor is needed, and | ||
190 | 213 | the x property of delegate instance will be set so as to be one pixel before | ||
191 | 214 | the top left of the current character. | ||
192 | 215 | |||
193 | 216 | Note that the root item of the delegate component must be a QQuickItem or | ||
194 | 217 | QQuickItem derived item. | ||
195 | 218 | |||
196 | 219 | \qmlproperty Component cursorDelegate | ||
197 | 220 | */ | ||
198 | 221 | property alias cursorDelegate: editor.cursorDelegate | ||
199 | 222 | |||
200 | 223 | /*! | ||
201 | 153 | The position of the cursor in the TextField. | 224 | The position of the cursor in the TextField. |
202 | 154 | 225 | ||
203 | 155 | \qmlproperty int cursorPosition | 226 | \qmlproperty int cursorPosition |
204 | @@ -157,21 +228,70 @@ | |||
205 | 157 | property alias cursorPosition: editor.cursorPosition | 228 | property alias cursorPosition: editor.cursorPosition |
206 | 158 | 229 | ||
207 | 159 | /*! | 230 | /*! |
209 | 160 | \preliminary | 231 | The rectangle where the standard text cursor is rendered within the text |
210 | 232 | input. Read only. | ||
211 | 233 | |||
212 | 234 | The position and height of a custom cursorDelegate are updated to follow | ||
213 | 235 | the cursorRectangle automatically when it changes. The width of the delegate | ||
214 | 236 | is unaffected by changes in the cursor rectangle. | ||
215 | 237 | |||
216 | 238 | \qmlproperty rectangle cursorRectangle | ||
217 | 239 | */ | ||
218 | 240 | property alias cursorRectangle: editor.cursorRectangle | ||
219 | 241 | |||
220 | 242 | /*! | ||
221 | 243 | Set to true when the TextField shows a cursor. | ||
222 | 244 | |||
223 | 245 | This property is set and unset when the TextField gets active focus, so that | ||
224 | 246 | other properties can be bound to whether the cursor is currently showing. | ||
225 | 247 | As it gets set and unset automatically, when you set the value yourself you | ||
226 | 248 | must keep in mind that your value may be overwritten. | ||
227 | 249 | |||
228 | 250 | It can be set directly in script, for example if a KeyProxy might forward keys | ||
229 | 251 | to it and you desire it to look active when this happens (but without actually | ||
230 | 252 | giving it active focus). | ||
231 | 253 | |||
232 | 254 | It should not be set directly on the item, like in the below QML, as the specified | ||
233 | 255 | value will be overridden an lost on focus changes. | ||
234 | 256 | \qml | ||
235 | 257 | TextField { | ||
236 | 258 | text: "Text" | ||
237 | 259 | cursorVisible: false | ||
238 | 260 | } | ||
239 | 261 | \endqml | ||
240 | 262 | In the above snippet the cursor will still become visible when the TextField | ||
241 | 263 | gains active focus. | ||
242 | 264 | |||
243 | 265 | \qmlproperty bool cursorVisible | ||
244 | 266 | */ | ||
245 | 267 | property alias cursorVisible: editor.cursorVisible | ||
246 | 268 | |||
247 | 269 | /*! | ||
248 | 270 | This is the text displayed in the TextField. | ||
249 | 271 | |||
250 | 272 | If echoMode is set to TextInput::Normal, this holds the same value as the | ||
251 | 273 | \l text property. Otherwise, this property holds the text visible to the | ||
252 | 274 | user, while the text property holds the actual entered text. | ||
253 | 275 | |||
254 | 276 | \qmlproperty string displayText | ||
255 | 277 | */ | ||
256 | 278 | property alias displayText: editor.displayText | ||
257 | 279 | |||
258 | 280 | /*! | ||
259 | 161 | Specifies how the text should be displayed in the TextField. | 281 | Specifies how the text should be displayed in the TextField. |
265 | 162 | 282 | \list | |
266 | 163 | - TextInput.Normal - Displays the text as it is. (Default) | 283 | \li - TextInput.Normal - Displays the text as it is. (Default) |
267 | 164 | - TextInput.Password - Displays asterixes instead of characters. | 284 | \li - TextInput.Password - Displays asterixes instead of characters. |
268 | 165 | - TextInput.NoEcho - Displays nothing. | 285 | \li - TextInput.NoEcho - Displays nothing. |
269 | 166 | - TextInput.PasswordEchoOnEdit - Displays characters as they are entered while | 286 | \li - TextInput.PasswordEchoOnEdit - Displays characters as they are entered while |
270 | 167 | editing, otherwise displays asterisks. | 287 | editing, otherwise displays asterisks. |
271 | 288 | \endlist | ||
272 | 168 | 289 | ||
274 | 169 | \qmlproperty enumeration echoMode | 290 | \qmlproperty enumeration echoMode |
275 | 170 | */ | 291 | */ |
276 | 171 | property alias echoMode: editor.echoMode | 292 | property alias echoMode: editor.echoMode |
277 | 172 | 293 | ||
278 | 173 | /*! | 294 | /*! |
279 | 174 | \preliminary | ||
280 | 175 | Font used in the TextField. | 295 | Font used in the TextField. |
281 | 176 | 296 | ||
282 | 177 | \qmlproperty font font | 297 | \qmlproperty font font |
283 | @@ -179,7 +299,6 @@ | |||
284 | 179 | property alias font: editor.font | 299 | property alias font: editor.font |
285 | 180 | 300 | ||
286 | 181 | /*! | 301 | /*! |
287 | 182 | \preliminary | ||
288 | 183 | Allows you to set an input mask on the TextField, restricting the text | 302 | Allows you to set an input mask on the TextField, restricting the text |
289 | 184 | inputs. See QLineEdit::inputMask for further details, as the exact same mask strings | 303 | inputs. See QLineEdit::inputMask for further details, as the exact same mask strings |
290 | 185 | are used by TextField. | 304 | are used by TextField. |
291 | @@ -189,7 +308,6 @@ | |||
292 | 189 | property alias inputMask: editor.inputMask | 308 | property alias inputMask: editor.inputMask |
293 | 190 | 309 | ||
294 | 191 | /*! | 310 | /*! |
295 | 192 | \preliminary | ||
296 | 193 | This property holds whether the TextInput has partial text input from an input method. | 311 | This property holds whether the TextInput has partial text input from an input method. |
297 | 194 | 312 | ||
298 | 195 | While it is composing an input method may rely on mouse or key events from the | 313 | While it is composing an input method may rely on mouse or key events from the |
299 | @@ -202,7 +320,6 @@ | |||
300 | 202 | property alias inputMethodComposing: editor.inputMethodComposing | 320 | property alias inputMethodComposing: editor.inputMethodComposing |
301 | 203 | 321 | ||
302 | 204 | /*! | 322 | /*! |
303 | 205 | \preliminary | ||
304 | 206 | Provides hints to the input method about the expected content of the text input and how it | 323 | Provides hints to the input method about the expected content of the text input and how it |
305 | 207 | should operate. | 324 | should operate. |
306 | 208 | 325 | ||
307 | @@ -211,37 +328,37 @@ | |||
308 | 211 | Flags that alter behaviour are: | 328 | Flags that alter behaviour are: |
309 | 212 | 329 | ||
310 | 213 | \list | 330 | \list |
312 | 214 | \li Qt.ImhHiddenText - Characters should be hidden, as is typically used when entering passwords. | 331 | \li - Qt.ImhHiddenText - Characters should be hidden, as is typically used when entering passwords. |
313 | 215 | This is automatically set when setting echoMode to \c TextInput.Password. | 332 | This is automatically set when setting echoMode to \c TextInput.Password. |
315 | 216 | \li Qt.ImhSensitiveData - Typed text should not be stored by the active input method | 333 | \li - Qt.ImhSensitiveData - Typed text should not be stored by the active input method |
316 | 217 | in any persistent storage like predictive user dictionary. | 334 | in any persistent storage like predictive user dictionary. |
318 | 218 | \li Qt.ImhNoAutoUppercase - The input method should not try to automatically switch to upper case | 335 | \li - Qt.ImhNoAutoUppercase - The input method should not try to automatically switch to upper case |
319 | 219 | when a sentence ends. | 336 | when a sentence ends. |
324 | 220 | \li Qt.ImhPreferNumbers - Numbers are preferred (but not required). | 337 | \li - Qt.ImhPreferNumbers - Numbers are preferred (but not required). |
325 | 221 | \li Qt.ImhPreferUppercase - Upper case letters are preferred (but not required). | 338 | \li - Qt.ImhPreferUppercase - Upper case letters are preferred (but not required). |
326 | 222 | \li Qt.ImhPreferLowercase - Lower case letters are preferred (but not required). | 339 | \li - Qt.ImhPreferLowercase - Lower case letters are preferred (but not required). |
327 | 223 | \li Qt.ImhNoPredictiveText - Do not use predictive text (i.e. dictionary lookup) while typing. | 340 | \li - Qt.ImhNoPredictiveText - Do not use predictive text (i.e. dictionary lookup) while typing. |
328 | 224 | 341 | ||
331 | 225 | \li Qt.ImhDate - The text editor functions as a date field. | 342 | \li - Qt.ImhDate - The text editor functions as a date field. |
332 | 226 | \li Qt.ImhTime - The text editor functions as a time field. | 343 | \li - Qt.ImhTime - The text editor functions as a time field. |
333 | 227 | \endlist | 344 | \endlist |
334 | 228 | 345 | ||
335 | 229 | Flags that restrict input (exclusive flags) are: | 346 | Flags that restrict input (exclusive flags) are: |
336 | 230 | 347 | ||
337 | 231 | \list | 348 | \list |
345 | 232 | \li Qt.ImhDigitsOnly - Only digits are allowed. | 349 | \li - Qt.ImhDigitsOnly - Only digits are allowed. |
346 | 233 | \li Qt.ImhFormattedNumbersOnly - Only number input is allowed. This includes decimal point and minus sign. | 350 | \li - Qt.ImhFormattedNumbersOnly - Only number input is allowed. This includes decimal point and minus sign. |
347 | 234 | \li Qt.ImhUppercaseOnly - Only upper case letter input is allowed. | 351 | \li - Qt.ImhUppercaseOnly - Only upper case letter input is allowed. |
348 | 235 | \li Qt.ImhLowercaseOnly - Only lower case letter input is allowed. | 352 | \li - Qt.ImhLowercaseOnly - Only lower case letter input is allowed. |
349 | 236 | \li Qt.ImhDialableCharactersOnly - Only characters suitable for phone dialing are allowed. | 353 | \li - Qt.ImhDialableCharactersOnly - Only characters suitable for phone dialing are allowed. |
350 | 237 | \li Qt.ImhEmailCharactersOnly - Only characters suitable for email addresses are allowed. | 354 | \li - Qt.ImhEmailCharactersOnly - Only characters suitable for email addresses are allowed. |
351 | 238 | \li Qt.ImhUrlCharactersOnly - Only characters suitable for URLs are allowed. | 355 | \li - Qt.ImhUrlCharactersOnly - Only characters suitable for URLs are allowed. |
352 | 239 | \endlist | 356 | \endlist |
353 | 240 | 357 | ||
354 | 241 | Masks: | 358 | Masks: |
355 | 242 | 359 | ||
356 | 243 | \list | 360 | \list |
358 | 244 | \li Qt.ImhExclusiveInputMask - This mask yields nonzero if any of the exclusive flags are used. | 361 | \li - Qt.ImhExclusiveInputMask - This mask yields nonzero if any of the exclusive flags are used. |
359 | 245 | \endlist | 362 | \endlist |
360 | 246 | 363 | ||
361 | 247 | \qmlproperty enumeration inputMethodHints | 364 | \qmlproperty enumeration inputMethodHints |
362 | @@ -249,7 +366,20 @@ | |||
363 | 249 | property alias inputMethodHints: editor.inputMethodHints | 366 | property alias inputMethodHints: editor.inputMethodHints |
364 | 250 | 367 | ||
365 | 251 | /*! | 368 | /*! |
367 | 252 | \preliminary | 369 | Returns the total number of characters in the TextField item. |
368 | 370 | |||
369 | 371 | If the TextField has an inputMask the length will include mask characters | ||
370 | 372 | and may differ from the length of the string returned by the text property. | ||
371 | 373 | |||
372 | 374 | This property can be faster than querying the length the text property as | ||
373 | 375 | it doesn't require any copying or conversion of the TextField's internal | ||
374 | 376 | string data. | ||
375 | 377 | |||
376 | 378 | \qmlproperty int length | ||
377 | 379 | */ | ||
378 | 380 | property alias length: editor.length | ||
379 | 381 | |||
380 | 382 | /*! | ||
381 | 253 | The maximum permitted length of the text in the TextField. | 383 | The maximum permitted length of the text in the TextField. |
382 | 254 | 384 | ||
383 | 255 | If the text is too long, it is truncated at the limit. | 385 | If the text is too long, it is truncated at the limit. |
384 | @@ -261,7 +391,27 @@ | |||
385 | 261 | property alias maximumLength: editor.maximumLength | 391 | property alias maximumLength: editor.maximumLength |
386 | 262 | 392 | ||
387 | 263 | /*! | 393 | /*! |
389 | 264 | \preliminary | 394 | Specifies how text should be selected using a mouse. |
390 | 395 | \list | ||
391 | 396 | \li -TextInput.SelectCharacters - The selection is updated with individual | ||
392 | 397 | characters. (Default) | ||
393 | 398 | \li -TextInput.SelectWords - The selection is updated with whole words. | ||
394 | 399 | \endlist | ||
395 | 400 | This property only applies when selectByMouse is true. | ||
396 | 401 | |||
397 | 402 | \qmlproperty enumeration mouseSelectionMode | ||
398 | 403 | */ | ||
399 | 404 | property alias mouseSelectionMode: editor.mouseSelectionMode | ||
400 | 405 | |||
401 | 406 | /*! | ||
402 | 407 | Whether the TextField should keep its selection when it loses active focus | ||
403 | 408 | to another item in the scene. By default this is set to false. | ||
404 | 409 | |||
405 | 410 | \qmlproperty bool persistentSelection | ||
406 | 411 | */ | ||
407 | 412 | property alias persistentSelection: editor.persistentSelection | ||
408 | 413 | |||
409 | 414 | /*! | ||
410 | 265 | Sets whether user input can modify the contents of the TextField. | 415 | Sets whether user input can modify the contents of the TextField. |
411 | 266 | 416 | ||
412 | 267 | If readOnly is set to true, then user input will not affect the | 417 | If readOnly is set to true, then user input will not affect the |
413 | @@ -273,15 +423,48 @@ | |||
414 | 273 | property alias readOnly: editor.readOnly | 423 | property alias readOnly: editor.readOnly |
415 | 274 | 424 | ||
416 | 275 | /*! | 425 | /*! |
417 | 426 | Override the default rendering type for this component. | ||
418 | 427 | |||
419 | 428 | Supported render types are: | ||
420 | 429 | \list | ||
421 | 430 | \li - Text.QtRendering - (default) | ||
422 | 431 | \li - Text.NativeRendering | ||
423 | 432 | \endlist | ||
424 | 433 | |||
425 | 434 | Select Text.NativeRendering if you prefer text to look native on the target | ||
426 | 435 | platform and do not require advanced features such as transformation of the | ||
427 | 436 | text. Using such features in combination with the NativeRendering render type | ||
428 | 437 | will lend poor and sometimes pixelated results. | ||
429 | 438 | |||
430 | 439 | \qmlproperty enumeration renderType | ||
431 | 440 | */ | ||
432 | 441 | property alias renderType: editor.renderType | ||
433 | 442 | |||
434 | 443 | /*! | ||
435 | 444 | Defaults to true. | ||
436 | 445 | |||
437 | 446 | If false, the user cannot use the mouse to select text, only can use it to | ||
438 | 447 | focus the input. | ||
439 | 448 | |||
440 | 449 | \qmlproperty bool selectByMouse | ||
441 | 276 | \preliminary | 450 | \preliminary |
442 | 451 | */ | ||
443 | 452 | property alias selectByMouse: virtualKbdHandler.enabled | ||
444 | 453 | |||
445 | 454 | /*! | ||
446 | 277 | This read-only property provides the text currently selected in the text input. | 455 | This read-only property provides the text currently selected in the text input. |
447 | 278 | 456 | ||
448 | 457 | It is equivalent to the following snippet, but is faster and easier to use. | ||
449 | 458 | \code | ||
450 | 459 | myTextInput.text.toString().substring(myTextInput.selectionStart, | ||
451 | 460 | myTextInput.selectionEnd); | ||
452 | 461 | \endcode | ||
453 | 462 | |||
454 | 279 | \qmlproperty string selectedText | 463 | \qmlproperty string selectedText |
455 | 280 | */ | 464 | */ |
457 | 281 | property alias selectedText: editor.selectedText | 465 | readonly property alias selectedText: editor.selectedText |
458 | 282 | 466 | ||
459 | 283 | /*! | 467 | /*! |
460 | 284 | \preliminary | ||
461 | 285 | The cursor position before the first character in the current selection. | 468 | The cursor position before the first character in the current selection. |
462 | 286 | 469 | ||
463 | 287 | This property is read-only. To change the selection, use select(start,end), | 470 | This property is read-only. To change the selection, use select(start,end), |
464 | @@ -292,7 +475,6 @@ | |||
465 | 292 | property alias selectionStart: editor.selectionStart | 475 | property alias selectionStart: editor.selectionStart |
466 | 293 | 476 | ||
467 | 294 | /*! | 477 | /*! |
468 | 295 | \preliminary | ||
469 | 296 | The cursor position after the last character in the current selection. | 478 | The cursor position after the last character in the current selection. |
470 | 297 | 479 | ||
471 | 298 | This property is read-only. To change the selection, use select(start,end), | 480 | This property is read-only. To change the selection, use select(start,end), |
472 | @@ -303,7 +485,6 @@ | |||
473 | 303 | property alias selectionEnd: editor.selectionEnd | 485 | property alias selectionEnd: editor.selectionEnd |
474 | 304 | 486 | ||
475 | 305 | /*! | 487 | /*! |
476 | 306 | \preliminary | ||
477 | 307 | The text in the TextField. | 488 | The text in the TextField. |
478 | 308 | 489 | ||
479 | 309 | \qmlproperty string text | 490 | \qmlproperty string text |
480 | @@ -311,7 +492,6 @@ | |||
481 | 311 | property alias text: editor.text | 492 | property alias text: editor.text |
482 | 312 | 493 | ||
483 | 313 | /*! | 494 | /*! |
484 | 314 | \preliminary | ||
485 | 315 | Allows you to set a validator on the TextInput. When a validator is set the | 495 | Allows you to set a validator on the TextInput. When a validator is set the |
486 | 316 | TextField will only accept input which leaves the text property in an acceptable | 496 | TextField will only accept input which leaves the text property in an acceptable |
487 | 317 | or intermediate state. The accepted signal will only be sent if the text is in | 497 | or intermediate state. The accepted signal will only be sent if the text is in |
488 | @@ -323,23 +503,25 @@ | |||
489 | 323 | 503 | ||
490 | 324 | \qml | 504 | \qml |
491 | 325 | import QtQuick 2.0 | 505 | import QtQuick 2.0 |
493 | 326 | TextInput{ | 506 | import Ubuntu.Components 0.1 |
494 | 507 | TextField{ | ||
495 | 327 | validator: IntValidator{bottom: 11; top: 31;} | 508 | validator: IntValidator{bottom: 11; top: 31;} |
496 | 328 | focus: true | 509 | focus: true |
497 | 329 | } | 510 | } |
498 | 330 | \endqml | 511 | \endqml |
499 | 331 | 512 | ||
500 | 513 | \sa acceptableInput, inputMask | ||
501 | 514 | |||
502 | 332 | \qmlproperty Validator validator | 515 | \qmlproperty Validator validator |
503 | 333 | */ | 516 | */ |
504 | 334 | property alias validator: editor.validator | 517 | property alias validator: editor.validator |
505 | 335 | 518 | ||
506 | 336 | /*! | 519 | /*! |
507 | 337 | \preliminary | ||
508 | 338 | Sets the horizontal alignment of the text within the item's width and height. | 520 | Sets the horizontal alignment of the text within the item's width and height. |
509 | 339 | By default, the text alignment follows the natural alignment of the text, for | 521 | By default, the text alignment follows the natural alignment of the text, for |
510 | 340 | example text that is read from left to right will be aligned to the left. | 522 | example text that is read from left to right will be aligned to the left. |
511 | 341 | 523 | ||
513 | 342 | TextInput does not have vertical alignment, as the natural height is exactly | 524 | TextField does not have vertical alignment, as the natural height is exactly |
514 | 343 | the height of the single line of text. If you set the height manually to something | 525 | the height of the single line of text. If you set the height manually to something |
515 | 344 | larger, TextInput will always be top aligned vertically. You can use anchors to | 526 | larger, TextInput will always be top aligned vertically. You can use anchors to |
516 | 345 | align it however you want within another item. | 527 | align it however you want within another item. |
517 | @@ -347,36 +529,51 @@ | |||
518 | 347 | The valid values for horizontalAlignment are TextInput.AlignLeft, | 529 | The valid values for horizontalAlignment are TextInput.AlignLeft, |
519 | 348 | TextInput.AlignRight and TextInput.AlignHCenter. | 530 | TextInput.AlignRight and TextInput.AlignHCenter. |
520 | 349 | 531 | ||
521 | 532 | Valid values for verticalAlignment are TextInput.AlignTop (default), TextInput.AlignBottom | ||
522 | 533 | TextInput.AlignVCenter. | ||
523 | 534 | |||
524 | 535 | When using the attached property LayoutMirroring::enabled to mirror application | ||
525 | 536 | layouts, the horizontal alignment of text will also be mirrored. However, | ||
526 | 537 | the property horizontalAlignment will remain unchanged. To query the effective | ||
527 | 538 | horizontal alignment of TextField, use the read-only property effectiveHorizontalAlignment. | ||
528 | 539 | |||
529 | 350 | \qmlproperty enumeration horizontalAlignment | 540 | \qmlproperty enumeration horizontalAlignment |
530 | 541 | \qmlproperty enumeration effectiveHorizontalAlignment | ||
531 | 542 | \qmlproperty enumeration verticalAlignment | ||
532 | 351 | */ | 543 | */ |
533 | 352 | property alias horizontalAlignment: editor.horizontalAlignment | 544 | property alias horizontalAlignment: editor.horizontalAlignment |
534 | 545 | /*! \internal */ | ||
535 | 546 | property alias effectiveHorizontalAlignment: editor.effectiveHorizontalAlignment | ||
536 | 547 | /*! \internal */ | ||
537 | 548 | property alias verticalAlignment: editor.verticalAlignment | ||
538 | 353 | 549 | ||
539 | 354 | /*! | 550 | /*! |
542 | 355 | \internal | 551 | This is the character displayed when echoMode is set to Password or |
543 | 356 | FIXME: property added for styling purposes | 552 | PasswordEchoOnEdit. By default it is the unicode character 2022. |
544 | 553 | |||
545 | 554 | If this property is set to a string with more than one character, the first | ||
546 | 555 | character is used. If the string is empty, the value is ignored and the property | ||
547 | 556 | is not set. | ||
548 | 557 | |||
549 | 558 | \qmlproperty string passwordCharacter | ||
550 | 357 | */ | 559 | */ |
551 | 358 | property alias passwordCharacter: editor.passwordCharacter | 560 | property alias passwordCharacter: editor.passwordCharacter |
552 | 359 | 561 | ||
553 | 360 | /*! | 562 | /*! |
558 | 361 | \internal | 563 | The text highlight color, used behind selections. |
555 | 362 | FIXME: property added for styling purposes | ||
556 | 363 | */ | ||
557 | 364 | property alias color: editor.color | ||
559 | 365 | 564 | ||
563 | 366 | /*! | 565 | \qmlproperty color selectionColor |
561 | 367 | \internal | ||
562 | 368 | FIXME: property added for styling purposes | ||
564 | 369 | */ | 566 | */ |
565 | 370 | property alias selectionColor: editor.selectionColor | 567 | property alias selectionColor: editor.selectionColor |
566 | 371 | 568 | ||
567 | 372 | /*! | 569 | /*! |
570 | 373 | \internal | 570 | The highlighted text color, used in selections. |
571 | 374 | FIXME: property added for styling purposes | 571 | |
572 | 572 | \qmlproperty color selctedTextColor | ||
573 | 375 | */ | 573 | */ |
574 | 376 | property alias selectedTextColor: editor.selectedTextColor | 574 | property alias selectedTextColor: editor.selectedTextColor |
575 | 377 | 575 | ||
576 | 378 | /*! | 576 | /*! |
577 | 379 | \preliminary | ||
578 | 380 | This handler is called when the Return or Enter key is pressed. Note that if | 577 | This handler is called when the Return or Enter key is pressed. Note that if |
579 | 381 | there is a validator or inputMask set on the text input, the handler will only | 578 | there is a validator or inputMask set on the text input, the handler will only |
580 | 382 | be emitted if the input is in an acceptable state. | 579 | be emitted if the input is in an acceptable state. |
581 | @@ -385,7 +582,6 @@ | |||
582 | 385 | 582 | ||
583 | 386 | 583 | ||
584 | 387 | /*! | 584 | /*! |
585 | 388 | \preliminary | ||
586 | 389 | Copies the currently selected text to the system clipboard. | 585 | Copies the currently selected text to the system clipboard. |
587 | 390 | */ | 586 | */ |
588 | 391 | function copy() | 587 | function copy() |
589 | @@ -394,7 +590,6 @@ | |||
590 | 394 | } | 590 | } |
591 | 395 | 591 | ||
592 | 396 | /*! | 592 | /*! |
593 | 397 | \preliminary | ||
594 | 398 | Moves the currently selected text to the system clipboard. | 593 | Moves the currently selected text to the system clipboard. |
595 | 399 | */ | 594 | */ |
596 | 400 | function cut() | 595 | function cut() |
597 | @@ -403,7 +598,6 @@ | |||
598 | 403 | } | 598 | } |
599 | 404 | 599 | ||
600 | 405 | /*! | 600 | /*! |
601 | 406 | \preliminary | ||
602 | 407 | Places the clipboard or the data given as parameter into the text input. | 601 | Places the clipboard or the data given as parameter into the text input. |
603 | 408 | The selected text will be replaces with the data. | 602 | The selected text will be replaces with the data. |
604 | 409 | */ | 603 | */ |
605 | @@ -424,7 +618,6 @@ | |||
606 | 424 | } | 618 | } |
607 | 425 | 619 | ||
608 | 426 | /*! | 620 | /*! |
609 | 427 | \preliminary | ||
610 | 428 | Removes active text selection. | 621 | Removes active text selection. |
611 | 429 | */ | 622 | */ |
612 | 430 | function deselect() | 623 | function deselect() |
613 | @@ -433,7 +626,13 @@ | |||
614 | 433 | } | 626 | } |
615 | 434 | 627 | ||
616 | 435 | /*! | 628 | /*! |
618 | 436 | \preliminary | 629 | Inserts \a text into the TextField at \a position. |
619 | 630 | */ | ||
620 | 631 | function insert(position, text) { | ||
621 | 632 | editor.insert(position, text); | ||
622 | 633 | } | ||
623 | 634 | |||
624 | 635 | /*! | ||
625 | 437 | This function returns the character position at x pixels from the left of | 636 | This function returns the character position at x pixels from the left of |
626 | 438 | the TextField. Position 0 is before the first character, position 1 is after | 637 | the TextField. Position 0 is before the first character, position 1 is after |
627 | 439 | the first character but before the second, and so on until position text.length, | 638 | the first character but before the second, and so on until position text.length, |
628 | @@ -443,11 +642,12 @@ | |||
629 | 443 | and for all x values after the last character this function returns text.length. | 642 | and for all x values after the last character this function returns text.length. |
630 | 444 | 643 | ||
631 | 445 | The cursor position type specifies how the cursor position should be resolved. | 644 | The cursor position type specifies how the cursor position should be resolved. |
634 | 446 | 645 | \list | |
635 | 447 | - TextInput.CursorBetweenCharacters - Returns the position between characters | 646 | \li - TextInput.CursorBetweenCharacters - Returns the position between characters |
636 | 448 | that is nearest x. | 647 | that is nearest x. |
638 | 449 | - TextInput.CursorOnCharacter - Returns the position before the character that | 648 | \li - TextInput.CursorOnCharacter - Returns the position before the character that |
639 | 450 | is nearest x. | 649 | is nearest x. |
640 | 650 | \endlist | ||
641 | 451 | */ | 651 | */ |
642 | 452 | function positionAt(x, position) | 652 | function positionAt(x, position) |
643 | 453 | { | 653 | { |
644 | @@ -458,7 +658,6 @@ | |||
645 | 458 | } | 658 | } |
646 | 459 | 659 | ||
647 | 460 | /*! | 660 | /*! |
648 | 461 | \preliminary | ||
649 | 462 | This function takes a character position and returns the rectangle that the | 661 | This function takes a character position and returns the rectangle that the |
650 | 463 | cursor would occupy, if it was placed at that character position. | 662 | cursor would occupy, if it was placed at that character position. |
651 | 464 | 663 | ||
652 | @@ -471,7 +670,6 @@ | |||
653 | 471 | } | 670 | } |
654 | 472 | 671 | ||
655 | 473 | /*! | 672 | /*! |
656 | 474 | \preliminary | ||
657 | 475 | Causes the text from start to end to be selected. | 673 | Causes the text from start to end to be selected. |
658 | 476 | 674 | ||
659 | 477 | If either start or end is out of range, the selection is not changed. | 675 | If either start or end is out of range, the selection is not changed. |
660 | @@ -485,7 +683,6 @@ | |||
661 | 485 | } | 683 | } |
662 | 486 | 684 | ||
663 | 487 | /*! | 685 | /*! |
664 | 488 | \preliminary | ||
665 | 489 | Causes all text to be selected. | 686 | Causes all text to be selected. |
666 | 490 | */ | 687 | */ |
667 | 491 | function selectAll() | 688 | function selectAll() |
668 | @@ -494,7 +691,6 @@ | |||
669 | 494 | } | 691 | } |
670 | 495 | 692 | ||
671 | 496 | /*! | 693 | /*! |
672 | 497 | \preliminary | ||
673 | 498 | Causes the word closest to the current cursor position to be selected. | 694 | Causes the word closest to the current cursor position to be selected. |
674 | 499 | */ | 695 | */ |
675 | 500 | function selectWord() | 696 | function selectWord() |
676 | @@ -511,9 +707,86 @@ | |||
677 | 511 | internal.activateEditor(); | 707 | internal.activateEditor(); |
678 | 512 | } | 708 | } |
679 | 513 | 709 | ||
680 | 710 | /*! | ||
681 | 711 | Returns true if the natural reading direction of the editor text found between | ||
682 | 712 | positions start and end is right to left. | ||
683 | 713 | */ | ||
684 | 714 | function isRightToLeft(start, end) { | ||
685 | 715 | return editor.isRightToLeft(start, end); | ||
686 | 716 | } | ||
687 | 717 | |||
688 | 718 | /*! | ||
689 | 719 | Moves the cursor to position and updates the selection according to the | ||
690 | 720 | optional mode parameter. (To only move the cursor, set the cursorPosition property.) | ||
691 | 721 | |||
692 | 722 | When this method is called it additionally sets either the selectionStart | ||
693 | 723 | or the selectionEnd (whichever was at the previous cursor position) to the | ||
694 | 724 | specified position. This allows you to easily extend and contract the selected | ||
695 | 725 | text range. | ||
696 | 726 | |||
697 | 727 | The selection mode specifies whether the selection is updated on a per character | ||
698 | 728 | or a per word basis. If not specified the selection mode will default to | ||
699 | 729 | TextInput.SelectCharacters. | ||
700 | 730 | \list | ||
701 | 731 | \li - TextInput.SelectCharacters - Sets either the selectionStart or selectionEnd | ||
702 | 732 | (whichever was at the previous cursor position) to the specified position. | ||
703 | 733 | \li - TextInput.SelectWords - Sets the selectionStart and selectionEnd to | ||
704 | 734 | include all words between the specified position and the previous cursor | ||
705 | 735 | position. Words partially in the range are included. | ||
706 | 736 | \endlist | ||
707 | 737 | |||
708 | 738 | For example, take this sequence of calls: | ||
709 | 739 | \code | ||
710 | 740 | cursorPosition = 5 | ||
711 | 741 | moveCursorSelection(9, TextInput.SelectCharacters) | ||
712 | 742 | moveCursorSelection(7, TextInput.SelectCharacters) | ||
713 | 743 | \endcode | ||
714 | 744 | This moves the cursor to position 5, extend the selection end from 5 to 9 | ||
715 | 745 | and then retract the selection end from 9 to 7, leaving the text from position | ||
716 | 746 | 5 to 7 selected (the 6th and 7th characters). | ||
717 | 747 | |||
718 | 748 | The same sequence with TextInput.SelectWords will extend the selection | ||
719 | 749 | start to a word boundary before or on position 5 and extend the selection | ||
720 | 750 | end to a word boundary on or past position 9. | ||
721 | 751 | */ | ||
722 | 752 | function moveCursorSelection(position, mode) { | ||
723 | 753 | editor.moveCursorSelection(position, mode) | ||
724 | 754 | } | ||
725 | 755 | |||
726 | 756 | /*! | ||
727 | 757 | Redoes the last operation if redo is \l {canRedo}{available}. | ||
728 | 758 | */ | ||
729 | 759 | function redo() { | ||
730 | 760 | editor.redo(); | ||
731 | 761 | } | ||
732 | 762 | |||
733 | 763 | /*! | ||
734 | 764 | Undoes the last operation if undo is \l {canUndo}{available}. Deselects any current | ||
735 | 765 | selection, and updates the selection start to the current cursor position. | ||
736 | 766 | */ | ||
737 | 767 | function undo() { | ||
738 | 768 | editor.undo(); | ||
739 | 769 | } | ||
740 | 770 | |||
741 | 771 | /*! | ||
742 | 772 | Removes the section of text that is between the start and end positions from the TextField. | ||
743 | 773 | */ | ||
744 | 774 | function remove(start, end) { | ||
745 | 775 | editor.remove(start, end); | ||
746 | 776 | } | ||
747 | 777 | |||
748 | 778 | /*! | ||
749 | 779 | Returns the section of text that is between the start and end positions. | ||
750 | 780 | |||
751 | 781 | If the TextField has an inputMask the length will include mask characters. | ||
752 | 782 | */ | ||
753 | 783 | function getText(start, end) { | ||
754 | 784 | return editor.getText(start, end); | ||
755 | 785 | } | ||
756 | 786 | |||
757 | 514 | // internals | 787 | // internals |
758 | 515 | 788 | ||
760 | 516 | /*! internal */ | 789 | /*! \internal */ |
761 | 517 | onVisibleChanged: { | 790 | onVisibleChanged: { |
762 | 518 | if (!visible) | 791 | if (!visible) |
763 | 519 | control.focus = false; | 792 | control.focus = false; |
764 | 520 | 793 | ||
765 | === modified file 'tests/unit_x11/tst_components/tst_textfield.qml' | |||
766 | --- tests/unit_x11/tst_components/tst_textfield.qml 2013-06-04 09:42:07 +0000 | |||
767 | +++ tests/unit_x11/tst_components/tst_textfield.qml 2013-07-03 10:36:26 +0000 | |||
768 | @@ -65,6 +65,8 @@ | |||
769 | 65 | function initTestCase() { | 65 | function initTestCase() { |
770 | 66 | textField.forceActiveFocus(); | 66 | textField.forceActiveFocus(); |
771 | 67 | compare(textField.focus, true, "TextField is focused"); | 67 | compare(textField.focus, true, "TextField is focused"); |
772 | 68 | // clear clipboard | ||
773 | 69 | Clipboard.clear(); | ||
774 | 68 | } | 70 | } |
775 | 69 | 71 | ||
776 | 70 | function test_0_popover() { | 72 | function test_0_popover() { |
777 | @@ -79,14 +81,64 @@ | |||
778 | 79 | compare(textField.acceptableInput,true,"acceptableInput true by default") | 81 | compare(textField.acceptableInput,true,"acceptableInput true by default") |
779 | 80 | } | 82 | } |
780 | 81 | 83 | ||
781 | 84 | function test_0_activeFocusOnPress() { | ||
782 | 85 | compare(textField.activeFocusOnPress, true,"activeFocusOnPress true by default") | ||
783 | 86 | } | ||
784 | 87 | |||
785 | 88 | function test_0_autoScroll() { | ||
786 | 89 | compare(textField.autoScroll, true,"autoScroll true by default") | ||
787 | 90 | } | ||
788 | 91 | |||
789 | 92 | function test_0_canPaste() { | ||
790 | 93 | compare(textField.canPaste, false,"calPaste false when clipboard is empty") | ||
791 | 94 | } | ||
792 | 95 | |||
793 | 96 | function test_0_canRedo() { | ||
794 | 97 | compare(textField.canRedo, false,"calRedo false when no data was entered") | ||
795 | 98 | } | ||
796 | 99 | |||
797 | 100 | function test_0_canUndo() { | ||
798 | 101 | compare(textField.canUndo, false,"calUndo false when no data entered") | ||
799 | 102 | } | ||
800 | 103 | |||
801 | 104 | function test_0_color() { | ||
802 | 105 | compare(textField.color, "#000000","color #000000 by default") | ||
803 | 106 | } | ||
804 | 107 | |||
805 | 108 | function test_0_contentWidth() { | ||
806 | 109 | compare(textField.contentWidth, 0,"contentWidth by default") | ||
807 | 110 | } | ||
808 | 111 | |||
809 | 112 | function test_0_contentHeight() { | ||
810 | 113 | // line size is the font pixel size + 3 dp | ||
811 | 114 | var lineSize = textField.font.pixelSize + units.dp(3) | ||
812 | 115 | compare(textField.contentHeight, lineSize,"contentHeight by default") | ||
813 | 116 | } | ||
814 | 117 | |||
815 | 118 | function test_0_cursorDelegate() { | ||
816 | 119 | verify(textField.cursorDelegate, "cursorDelegate set by default") | ||
817 | 120 | } | ||
818 | 121 | |||
819 | 82 | function test_0_cursorPosition() { | 122 | function test_0_cursorPosition() { |
821 | 83 | compare(textField.cursorPosition,0,"cursorPosition 0 by default") | 123 | compare(textField.cursorPosition, 0, "cursorPosition 0 by default") |
822 | 124 | } | ||
823 | 125 | |||
824 | 126 | function test_0_cursorRectangle() { | ||
825 | 127 | compare(textField.cursorRectangle, Qt.rect(0, 0, 0, 0), "cursorRectangle 0 by default") | ||
826 | 128 | } | ||
827 | 129 | |||
828 | 130 | function test_0_cursorVisible() { | ||
829 | 131 | compare(textField.cursorVisible, true, "cursorVisible true by default") | ||
830 | 84 | } | 132 | } |
831 | 85 | 133 | ||
832 | 86 | function test_0_customSoftwareInputPanel() { | 134 | function test_0_customSoftwareInputPanel() { |
833 | 87 | compare(textField.customSoftwareInputPanel,null,"customSoftwareInputPanel is null by default") | 135 | compare(textField.customSoftwareInputPanel,null,"customSoftwareInputPanel is null by default") |
834 | 88 | } | 136 | } |
835 | 89 | 137 | ||
836 | 138 | function test_0_displayText() { | ||
837 | 139 | compare(textField.displayText, "", "displayText empty by default") | ||
838 | 140 | } | ||
839 | 141 | |||
840 | 90 | function test_0_echoMode() { | 142 | function test_0_echoMode() { |
841 | 91 | compare(textField.echoMode, TextInput.Normal,"echoMode is TextInput.Normal by default") | 143 | compare(textField.echoMode, TextInput.Normal,"echoMode is TextInput.Normal by default") |
842 | 92 | } | 144 | } |
843 | @@ -101,6 +153,12 @@ | |||
844 | 101 | verify((textField.font),"font is set") | 153 | verify((textField.font),"font is set") |
845 | 102 | } | 154 | } |
846 | 103 | 155 | ||
847 | 156 | function test_0_alignments() { | ||
848 | 157 | compare(textField.horizontalAlignment, TextInput.AlignLeft, "horizontalAlignmen is Left by default") | ||
849 | 158 | compare(textField.effectiveHorizontalAlignment, TextInput.AlignLeft, "effectiveHorizontalAlignmen is Left by default") | ||
850 | 159 | compare(textField.verticalAlignment, TextInput.AlignTop, "verticalAlignmen is Top by default") | ||
851 | 160 | } | ||
852 | 161 | |||
853 | 104 | function test_hasClearButton() { | 162 | function test_hasClearButton() { |
854 | 105 | compare(textField.hasClearButton, true, "hasClearButton is false by default") | 163 | compare(textField.hasClearButton, true, "hasClearButton is false by default") |
855 | 106 | textField.hasClearButton = false | 164 | textField.hasClearButton = false |
856 | @@ -119,10 +177,42 @@ | |||
857 | 119 | compare(textField.inputMethodHints, Qt.ImhNone, "inputMethodHints is Qt.ImhNone by default") | 177 | compare(textField.inputMethodHints, Qt.ImhNone, "inputMethodHints is Qt.ImhNone by default") |
858 | 120 | } | 178 | } |
859 | 121 | 179 | ||
860 | 180 | function test_0_length() { | ||
861 | 181 | compare(textField.length, 0, "length is 0 by default") | ||
862 | 182 | } | ||
863 | 183 | |||
864 | 122 | function test_0_maximumLength() { | 184 | function test_0_maximumLength() { |
865 | 123 | compare(textField.maximumLength, 32767, "maximumLength is 32767 by default") | 185 | compare(textField.maximumLength, 32767, "maximumLength is 32767 by default") |
866 | 124 | } | 186 | } |
867 | 125 | 187 | ||
868 | 188 | function test_0_mouseSelectionMode() { | ||
869 | 189 | compare(textField.mouseSelectionMode, TextInput.SelectCharacters, "mouseSelectionMode default") | ||
870 | 190 | } | ||
871 | 191 | |||
872 | 192 | function test_0_passwordCharacter() { | ||
873 | 193 | compare(textField.passwordCharacter, "\u2022", "passwordCharacter default") | ||
874 | 194 | } | ||
875 | 195 | |||
876 | 196 | function test_0_persistentSelection() { | ||
877 | 197 | compare(textField.persistentSelection, false, "persistentSelection default") | ||
878 | 198 | } | ||
879 | 199 | |||
880 | 200 | function test_0_renderType() { | ||
881 | 201 | compare(textField.renderType, Text.QtRendering, "renderType default") | ||
882 | 202 | } | ||
883 | 203 | |||
884 | 204 | function test_0_selectByMouse() { | ||
885 | 205 | compare(textField.selectByMouse, true, "selectByMouse default") | ||
886 | 206 | } | ||
887 | 207 | |||
888 | 208 | function test_0_selectedTextColor() { | ||
889 | 209 | compare(textField.selectedTextColor, "#f3f3e7", "selectedTextColor default") | ||
890 | 210 | } | ||
891 | 211 | |||
892 | 212 | function test_0_selectionColor() { | ||
893 | 213 | compare(textField.selectionColor, "#19b6ee", "selectionColor default") | ||
894 | 214 | } | ||
895 | 215 | |||
896 | 126 | function test_0_placeholderText() { | 216 | function test_0_placeholderText() { |
897 | 127 | compare(textField.placeholderText, "", "placeholderText is '' by default") | 217 | compare(textField.placeholderText, "", "placeholderText is '' by default") |
898 | 128 | } | 218 | } |
899 | @@ -197,6 +287,64 @@ | |||
900 | 197 | compare(textField.keyReleaseData, Qt.Key_Control, "Key release filtered"); | 287 | compare(textField.keyReleaseData, Qt.Key_Control, "Key release filtered"); |
901 | 198 | } | 288 | } |
902 | 199 | 289 | ||
903 | 290 | function test_1_undo_redo() { | ||
904 | 291 | textField.readOnly = false; | ||
905 | 292 | textField.text = ""; | ||
906 | 293 | textField.focus = true; | ||
907 | 294 | keyClick(Qt.Key_T); keyClick(Qt.Key_E); keyClick(Qt.Key_S); keyClick(Qt.Key_T); | ||
908 | 295 | compare(textField.text, "test", "new text"); | ||
909 | 296 | if (!textField.canUndo) expectFail("", "undo is not allowed in this input"); | ||
910 | 297 | textField.undo(); | ||
911 | 298 | compare(textField.text, "", "undone"); | ||
912 | 299 | textField.redo(); | ||
913 | 300 | compare(textField.text, "test", "redone"); | ||
914 | 301 | } | ||
915 | 302 | |||
916 | 303 | function test_1_getText() { | ||
917 | 304 | textField.text = "this is a longer text"; | ||
918 | 305 | compare(textField.getText(0, 10), "this is a ", "getText(0, 10)"); | ||
919 | 306 | compare(textField.getText(10, 0), "this is a ", "getText(10, 0)"); | ||
920 | 307 | compare(textField.getText(0), "", "getText(0)"); | ||
921 | 308 | compare(textField.getText(4, 0), "this", "getText(4, 0)"); | ||
922 | 309 | } | ||
923 | 310 | |||
924 | 311 | function test_1_removeText() { | ||
925 | 312 | textField.text = "this is a longer text"; | ||
926 | 313 | textField.remove(0, 10); | ||
927 | 314 | compare(textField.text, "longer text", "remove(0, 10)"); | ||
928 | 315 | |||
929 | 316 | textField.text = "this is a longer text"; | ||
930 | 317 | textField.remove(10, 0); | ||
931 | 318 | compare(textField.text, "longer text", "remove(0, 10)"); | ||
932 | 319 | |||
933 | 320 | textField.text = "this is a longer text"; | ||
934 | 321 | textField.remove(0); | ||
935 | 322 | compare(textField.text, "this is a longer text", "remove(0)"); | ||
936 | 323 | |||
937 | 324 | textField.text = "this is a longer text"; | ||
938 | 325 | textField.remove(4, 0); | ||
939 | 326 | compare(textField.text, " is a longer text", "remove(4, 0)"); | ||
940 | 327 | |||
941 | 328 | textField.text = "this is a longer text"; | ||
942 | 329 | textField.select(0, 4); | ||
943 | 330 | textField.remove(); | ||
944 | 331 | compare(textField.text, "this is a longer text", "select(0, 4) && remove()"); | ||
945 | 332 | } | ||
946 | 333 | |||
947 | 334 | function test_1_moveCursorSelection() { | ||
948 | 335 | textField.text = "this is a longer text"; | ||
949 | 336 | textField.cursorPosition = 5; | ||
950 | 337 | textField.moveCursorSelection(9, TextInput.SelectCharacters); | ||
951 | 338 | compare(textField.selectedText, "is a", "moveCursorSelection from 5 to 9, selecting the text"); | ||
952 | 339 | } | ||
953 | 340 | |||
954 | 341 | function test_1_isRightToLeft() { | ||
955 | 342 | textField.text = "this is a longer text"; | ||
956 | 343 | compare(textField.isRightToLeft(0), false, "isRightToLeft(0)"); | ||
957 | 344 | compare(textField.isRightToLeft(0, 0), false, "isRightToLeft(0, 0)"); | ||
958 | 345 | compare(textField.isRightToLeft(5, 10), false, "isRightToLeft(5, 10)"); | ||
959 | 346 | } | ||
960 | 347 | |||
961 | 200 | function test_cut() { | 348 | function test_cut() { |
962 | 201 | Clipboard.clear(); | 349 | Clipboard.clear(); |
963 | 202 | textField.readOnly = false; | 350 | textField.readOnly = false; |
PASSED: Continuous integration, rev:578 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- ci/264/ jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-amd64- ci/121 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-armhf- ci/121 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-armhf- ci/121/ artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ ubuntu- ui-toolkit- ci/264/ rebuild
http://