QML UI: better simulation of onPressed in TextField

Prior to Qt Quick Components 2.1 there was no onPressed signal for a
TextField; in order to be able to build against Qt 5.7 (which comes with
Qt Quick Components 2.0) we need to work around the lack of this signal.
This code seems to do a pretty good job at simulating it.

My attempt in commit 73c66e1d7d ("QML UI: make run with Qt 5.7 again")
didn't work so well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-04-14 14:03:51 -07:00
parent ee4ae49d37
commit c00b14af9a

View file

@ -13,7 +13,13 @@ TextField {
onTextChanged: {
textUpdateTimer.restart();
}
Keys.onPressed: frame.shouldShow = !frame.shouldShow
onFocusChanged: frame.shouldShow = focus
onVisibleChanged: {
if (visible) {
focus = false
frame.shouldShow = false
}
}
Keys.onUpPressed: {
hintsView.currentIndex--;
}