on xenial help sign in
Allow ENTER/RETURN in a TextField to accept a snap-decision notification.
commitbf7825b910a3f363c0eed322219a50bc83672099 authorMirco Müller <mirco.mueller@canonical.com> dateMon 21 Jul 2014, 12:59 (12 years ago) parent70f90d1
2 files changed+20
qml/Notifications/Notification.qml+1 qml/Notifications/NotificationMenuItemFactory.qml+19
qml/Notifications/Notification.qml+1
@@ -344,6 +344,7 @@ Item {
344344 objectName: "button" + index
345345 width: buttonRow.width / 2 - spacing
346346 text: loader.actionLabel
347+ property string actionId: loader.actionId
347348 gradient: notification.hints["x-canonical-private-button-tint"] == "true" && index == 0 ? greenGradient : darkgreyGradient
348349 onClicked: notification.notification.invokeAction(loader.actionId)
349350 }
qml/Notifications/NotificationMenuItemFactory.qml+19
@@ -65,6 +65,21 @@ Loader {
6565 text: menuData.label
6666 }
6767
68+ function findChild(obj, objectName) {
69+ var childs = new Array(0);
70+ childs.push(obj)
71+ while (childs.length > 0) {
72+ if (childs[0].objectName == objectName) {
73+ return childs[0]
74+ }
75+ for (var i in childs[0]["children"]) {
76+ childs.push(childs[0]["children"][i])
77+ }
78+ childs.splice(0, 1);
79+ }
80+ return null;
81+ }
82+
6883 TextField {
6984 id: textfield
7085
@@ -79,6 +94,10 @@ Loader {
7994 onTextChanged: {
8095 menuModel.changeState(menuIndex, text);
8196 }
97+ onAccepted: {
98+ var accept = findChild(notification, "button0")
99+ notification.notification.invokeAction(accept.actionId)
100+ }
82101 }
83102
84103 Row {