From 90b4528b846542bfa6f0723487315140b9de17b4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 17 Sep 2019 18:10:59 +0200 Subject: Avoid discouraged patterns in examples In particular, use required properties where applicable, explicitly import QtQml where we use it, avoid unqualified access into the root scope of a component, use JavaScript functions with explicit parameters as signal handlers. Change-Id: I3eaaba47cc3c7a2a12d488e36f9eec145cedbb0e Reviewed-by: Fabian Kosmale Reviewed-by: Shawn Rutledge --- examples/quick/keyinteraction/focus/focus.qml | 34 ++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'examples/quick/keyinteraction/focus/focus.qml') diff --git a/examples/quick/keyinteraction/focus/focus.qml b/examples/quick/keyinteraction/focus/focus.qml index e07df57697..9db9ab48bc 100644 --- a/examples/quick/keyinteraction/focus/focus.qml +++ b/examples/quick/keyinteraction/focus/focus.qml @@ -48,6 +48,7 @@ ** ****************************************************************************/ +import QtQml 2.1 import QtQuick 2.1 import "Core" @@ -67,20 +68,45 @@ Rectangle { id: tabMenu y: 160; width: parent.width; height: 160 + keyUpTarget: listMenu + keyDownTarget: gridMenu + focus: true activeFocusOnTab: true + + onActiveFocusChanged: { + if (activeFocus) + mainView.state = "showTabViews" + } } GridMenu { id: gridMenu y: 320; width: parent.width; height: 320 activeFocusOnTab: true + + keyUpTarget: tabMenu + keyDownTarget: listMenu + keyLeftTarget: contextMenu + + onActiveFocusChanged: { + if (activeFocus) + mainView.state = "showGridViews" + } } ListMenu { id: listMenu y: 640; width: parent.width; height: 320 activeFocusOnTab: true + + keyUpTarget: gridMenu + keyLeftTarget: contextMenu + + onActiveFocusChanged: { + if (activeFocus) + mainView.state = "showListViews" + } } Rectangle { @@ -129,7 +155,13 @@ Rectangle { } } - ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height } + ContextMenu { + keyRightTarget: mainView + id: contextMenu + x: -265 + width: 260 + height: parent.height + } states: State { name: "contextMenuOpen" -- cgit v1.2.3