This is caused because if predictive text input. Text is not commited to
component until word separator entered, word is choosed or focus is lost.
21.01.2015 19:02, Thomas Amler пишет:
Hi,
I have a problem concerning the RegExpValidator of a TextField. This
is the code:
TextField {
id: cameraManufacturer
width: parent.width
label: qsTr("Manufacturer")
placeholderText: label
text: editCameraManufacturer
validator: RegExpValidator { regExp: /^.{3,60}$/ }
EnterKey.enabled: errorHighlight === false ? true : false
EnterKey.iconSource: "image://theme/icon-m-enter-next"
EnterKey.onClicked: cameraModel.focus = true
onErrorHighlightChanged: checkContent()
onTextChanged: console.log(errorHighlight + "#" +
acceptableInput)
}
The validator works as expected on the Emulator. It reacts on every
text change in the field and changes the errorHighlight Status to
false if the regExp matches and vice versa. Also the field gets marked
red if errorHighlight is true and so on.
But if I'm using the same code on my Jolla the Validator only changes
the errorHighlight value if I change the focus to another TextField.
If I change back to the first TextField and change some characters, I
suddenly get an errorHighlight = true although the RegExp should match
the text.
As you can see I also integrated some console debugging. This makes
the problem even more strange. On the Emulator everything works fine.
errorHighlight is "true" until the third character is entered and is
logged as "false" when I enter the fourth character. Corresponding
behaviour can be seen with the acceptableInput property. It is false
until I enter the third character and with the third logging event it
is logged as true. So both are logged as true with log line three, but
this might be related to the onTextChanged Event, which should be ok I
think.
This is the output on the Emulator:
[D] onTextChanged:122 - true#false
[D] onTextChanged:122 - true#false
[D] onTextChanged:122 - true#true
[D] onTextChanged:122 - false#true
On my Jolla errorHighlight is ALWAYS "true" and accaptableInput is
ALWAYS "false". Output (timestamp and other useless garbage has been
wiped) for Jolla:
[D] onTextChanged:122 - true#false
[D] onTextChanged:122 - true#false
[D] onTextChanged:122 - true#false
[D] onTextChanged:122 - true#false
Now comes the really weird thing on the Jolla... Directly after
switching focus (not pressing any key, only tapping on the next
TextField) to another TextField I get this:
[D] onTextChanged:122 - true#true
[D] onTextChanged:122 - false#true
This doesn't happen in the Emulator!!!
WTF is going on?!
I'm really confused about this different behaviour and I couldn't find
a way to workaround this. I also have other TextFields using a
DoubleValidator which works quite fine.
If anyone knows what I'm doing wrong... Any help is appreciated! :-)
_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to
devel-unsubscr...@lists.sailfishos.org
_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org