summaryrefslogtreecommitdiffstats
path: root/framework/qml/AutocompleteLineEdit.qml
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-23 20:05:31 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-23 20:05:31 +0200
commitfa790f59ec52b36ef4c25905073c3b0069deb08d (patch)
treeb59099592e7098b8c42481bba55acda77e902569 /framework/qml/AutocompleteLineEdit.qml
parentdc50471a72c9310db3dd9149be1311e9502bdd9f (diff)
downloadkube-fa790f59ec52b36ef4c25905073c3b0069deb08d.tar.gz
kube-fa790f59ec52b36ef4c25905073c3b0069deb08d.zip
Keyboard focus handling
Diffstat (limited to 'framework/qml/AutocompleteLineEdit.qml')
-rw-r--r--framework/qml/AutocompleteLineEdit.qml21
1 files changed, 18 insertions, 3 deletions
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 {
30 property string searchTerm 30 property string searchTerm
31 property variant model 31 property variant model
32 32
33 signal aborted()
34
33 selectByMouse: true 35 selectByMouse: true
34 36
35 onTextChanged: { 37 onTextChanged: {
@@ -38,9 +40,17 @@ Kube.TextField {
38 startCompleting() 40 startCompleting()
39 } else { 41 } else {
40 searchTerm = "" 42 searchTerm = ""
41 abort() 43 popup.close()
42 } 44 }
43 } 45 }
46
47 onEditingFinished: {
48 console.warn("on editing finished")
49 accept()
50 }
51
52 validator: RegExpValidator { regExp: /.+/ }
53
44 Keys.onDownPressed: { 54 Keys.onDownPressed: {
45 listView.incrementCurrentIndex() 55 listView.incrementCurrentIndex()
46 } 56 }
@@ -58,7 +68,11 @@ Kube.TextField {
58 } 68 }
59 } 69 }
60 Keys.onReturnPressed: { 70 Keys.onReturnPressed: {
61 accept() 71 if (acceptableInput) {
72 accept()
73 } else {
74 abort()
75 }
62 } 76 }
63 Keys.onEscapePressed: { 77 Keys.onEscapePressed: {
64 abort() 78 abort()
@@ -76,11 +90,12 @@ Kube.TextField {
76 root.text = listView.currentItem.text; 90 root.text = listView.currentItem.text;
77 } 91 }
78 popup.close() 92 popup.close()
79 root.accepted(); 93 root.accepted()
80 } 94 }
81 95
82 function abort() { 96 function abort() {
83 popup.close() 97 popup.close()
98 root.aborted()
84 } 99 }
85 100
86 Controls2.Popup { 101 Controls2.Popup {