on xenial help sign in
fix focus with selec/enter/escape in spread
commite7ba9da494ee3bba14ff7190bf746f63d6e2556b authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 5 Aug 2016, 19:00 (10 years ago) parent2a70f10
2 files changed+13−5
qml/Stage/Spread/Spread.qml+3−2 qml/Stage/Stage.qml+10−3
qml/Stage/Spread/Spread.qml+3−2
@@ -21,6 +21,7 @@ Item {
2121 property real leftStackScale: .82
2222 property real rightStackScale: 1
2323
24+ signal leaveSpread()
2425
2526 // Calculated stuff
2627 readonly property int totalItemCount: model.count
@@ -123,12 +124,12 @@ Item {
123124 event.accepted = true;
124125 break;
125126 case Qt.Key_Escape:
126− spreadItem.highlightedIndex = -1
127+ highlightedIndex = -1
127128 // Falling through intentionally
128129 case Qt.Key_Enter:
129130 case Qt.Key_Return:
130131 case Qt.Key_Space:
131− root.state = ""
132+ root.leaveSpread();
132133 event.accepted = true;
133134 }
134135 }
qml/Stage/Stage.qml+10−3
@@ -50,6 +50,8 @@ AbstractStage {
5050
5151 orientationChangesEnabled: true
5252
53+ onAltTabPressedChanged: priv.goneToSpread = altTabPressed
54+
5355 GlobalShortcut {
5456 id: closeWindowShortcut
5557 shortcut: Qt.AltModifier|Qt.Key_F4
@@ -290,7 +292,7 @@ AbstractStage {
290292
291293 states: [
292294 State {
293− name: "spread"; when: root.altTabPressed || priv.goneToSpread
295+ name: "spread"; when: priv.goneToSpread
294296 PropertyChanges { target: floatingFlickable; enabled: true }
295297 PropertyChanges { target: spreadItem; focus: true }
296298 },
@@ -330,8 +332,9 @@ AbstractStage {
330332 Transition {
331333 from: "spread"
332334 SequentialAnimation {
333− ScriptAction { script: {
334− var item = appRepeater.itemAt(spreadItem.highlightedIndex);
335+ ScriptAction {
336+ script: {
337+ var item = appRepeater.itemAt(Math.max(0, spreadItem.highlightedIndex));
335338 item.claimFocus();
336339 item.playFocusAnimation();
337340 }
@@ -368,6 +371,10 @@ AbstractStage {
368371 leftMargin: root.leftMargin
369372 model: root.topLevelSurfaceList
370373 z: 10
374+
375+ onLeaveSpread: {
376+ priv.goneToSpread = false;
377+ }
371378 }
372379
373380 Connections {