From fa790f59ec52b36ef4c25905073c3b0069deb08d Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 23 Jul 2017 20:05:31 +0200 Subject: Keyboard focus handling --- framework/qml/AutocompleteLineEdit.qml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'framework') diff --git a/framework/qml/AutocompleteLineEdit.qml b/framework/qml/AutocompleteLineEdit.qml index f963095a..1be8f7eb 100644 --- a/framework/qml/AutocompleteLineEdit.qml +++ b/framework/qml/AutocompleteLineEdit.qml @@ -30,6 +30,8 @@ Kube.TextField { property string searchTerm property variant model + signal aborted() + selectByMouse: true onTextChanged: { @@ -38,9 +40,17 @@ Kube.TextField { startCompleting() } else { searchTerm = "" - abort() + popup.close() } } + + onEditingFinished: { + console.warn("on editing finished") + accept() + } + + validator: RegExpValidator { regExp: /.+/ } + Keys.onDownPressed: { listView.incrementCurrentIndex() } @@ -58,7 +68,11 @@ Kube.TextField { } } Keys.onReturnPressed: { - accept() + if (acceptableInput) { + accept() + } else { + abort() + } } Keys.onEscapePressed: { abort() @@ -76,11 +90,12 @@ Kube.TextField { root.text = listView.currentItem.text; } popup.close() - root.accepted(); + root.accepted() } function abort() { popup.close() + root.aborted() } Controls2.Popup { -- cgit v1.2.3