Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
4.7.3
-
None
-
Windows XPSP3, QtCreator 2.2, Qt 4.7.3
Description
The behavior of this graphic element was developed intending to satisfy desktop applications. Now we have QML introduced and it's going to fill a huge part of GUI implementations which are mostly touch screen oriented applications. This in turn involve A LOT of on-screen software input controls and right now the input mask functionality and TextInput interface for retreiving the typed value is simply useless for them. Just because there's no way to easily work (read/update) with the contents of the masked/validated control programmatically. The properties "text" and "displayValue" both return strings that should be specially parsed to cut out the mask characters (that were just a visual need). There's nothing like append() method or rawValue() method (to be used as "textInput.text = input.rawValue + anotherCharacter").
The set validator in turn lets modify the "text" property freely and works only when hardware key events come.
In my project for self-service kiosks I came across this trying to implement on-screen keyboard/keypad. Just impossible to use a trivial code to ask a user to enter his phone number in a nicely masked field. Having all "almost-fit" graphic controls I still end up with a lot of code that just repeats the input mask qt internals but doing just another simple thing - adding a character to the QML TextInput in a software way.
Another use case:
A customer can but not required to fill his contract number looking like "11-Z". A TextInput with mask "99-A;*" is used. The field is only acceptable if the customer doesn't enter anything or enters a correct number. The customer decides to skip this field. How the application would know if it can proceed (to show the button "Next")?
TextInput.acceptableInput gives false
TextInput.text gives "-"
TextInput.displayValue gives "*-"
For now an ugly workaround is to remember how displayValue looks right after creating the TextInput element and further compare against it as an "empty value".
Please consider improvements for the QML TextInput element to provide easy managing its value progammatically.
(input mask behavior inconsistence for QML also showed here: QTBUG-19264)