on xenial help sign in
return a bool so that we can accept the event from QML
05d9ed4Lukáš Tinkl
plugins/Utils/tabfocusfence.cpp+6−2
@@ -25,26 +25,30 @@ TabFocusFenceItem::TabFocusFenceItem(QQuickItem *parent) : QQuickItem(parent)
25 setFlag(ItemIsFocusScope);
25 setFlag(ItemIsFocusScope);
26}
26}
27
27
28−void TabFocusFenceItem::focusNext()
28+bool TabFocusFenceItem::focusNext()
29{
29{
30 QQuickItem * current = scopedFocusItem();
30 QQuickItem * current = scopedFocusItem();
31 if (current) {
31 if (current) {
32 QQuickItem * next = scopedFocusItem()->nextItemInFocusChain(true);
32 QQuickItem * next = scopedFocusItem()->nextItemInFocusChain(true);
33 if (next) {
33 if (next) {
34 next->setFocus(true, Qt::TabFocusReason);
34 next->setFocus(true, Qt::TabFocusReason);
35+ return true;
35 }
36 }
36 }
37 }
38+ return false;
37}
39}
38
40
39−void TabFocusFenceItem::focusPrev()
41+bool TabFocusFenceItem::focusPrev()
40{
42{
41 QQuickItem * current = scopedFocusItem();
43 QQuickItem * current = scopedFocusItem();
42 if (current) {
44 if (current) {
43 QQuickItem * prev = scopedFocusItem()->nextItemInFocusChain(false);
45 QQuickItem * prev = scopedFocusItem()->nextItemInFocusChain(false);
44 if (prev) {
46 if (prev) {
45 prev->setFocus(true, Qt::BacktabFocusReason);
47 prev->setFocus(true, Qt::BacktabFocusReason);
48+ return true;
46 }
49 }
47 }
50 }
51+ return false;
48}
52}
49
53
50void TabFocusFenceItem::keyPressEvent(QKeyEvent *event)
54void TabFocusFenceItem::keyPressEvent(QKeyEvent *event)
plugins/Utils/tabfocusfence.h+2−2
@@ -28,8 +28,8 @@ Q_OBJECT
28public:
28public:
29 TabFocusFenceItem(QQuickItem *parent = nullptr);
29 TabFocusFenceItem(QQuickItem *parent = nullptr);
30
30
31− Q_INVOKABLE void focusNext();
31+ Q_INVOKABLE bool focusNext();
32− Q_INVOKABLE void focusPrev();
32+ Q_INVOKABLE bool focusPrev();
33
33
34 void keyPressEvent(QKeyEvent *event) override;
34 void keyPressEvent(QKeyEvent *event) override;
35 void keyReleaseEvent(QKeyEvent *event) override;
35 void keyReleaseEvent(QKeyEvent *event) override;
qml/Components/ShellDialog.qml+2−2
@@ -62,10 +62,10 @@ Dialog {
62 spacing: units.gu(2)
62 spacing: units.gu(2)
63 }
63 }
64 Keys.onDownPressed: {
64 Keys.onDownPressed: {
65− focusNext();
65+ event.accepted = focusNext();
66 }
66 }
67 Keys.onUpPressed: {
67 Keys.onUpPressed: {
68− focusPrev();
68+ event.accepted = focusPrev();
69 }
69 }
70 }
70 }
71}
71}