[vlc-devel] [PATCH 11/14] qml: recursively traverse disabled NavigableFocusScope

Pierre Lamot pierre at videolabs.io
Thu Feb 6 13:56:48 CET 2020


  The previous behavior was to traverse sibiling until we find one a focusable
  one. This caused problem when the last sibiling in chain wasn't focusable as
  it was unable to continue with the parent sibiling.

  This allows to handle the case where a disabled focusable item is last
  in chain. It assumes items would behabe sanely when non focusable (have a
  sibiling or parent defined)
---
 .../qt/widgets/qml/NavigableFocusScope.qml    | 48 ++++++++++---------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/modules/gui/qt/widgets/qml/NavigableFocusScope.qml b/modules/gui/qt/widgets/qml/NavigableFocusScope.qml
index 3bf58fe1f8..85e7b3b3bc 100644
--- a/modules/gui/qt/widgets/qml/NavigableFocusScope.qml
+++ b/modules/gui/qt/widgets/qml/NavigableFocusScope.qml
@@ -52,12 +52,12 @@ FocusScope {
 
     function defaultNavigationUp(index) {
         if (navigationUpItem) {
-            var item = navigationUpItem
-            while (item && (!item.visible || !item.enabled || !(item.navigable === undefined || item.navigable))) {
-                item = item.navigationUpItem
-            }
-            if (item) {
-                item.forceActiveFocus()
+            if (navigationUpItem.visible
+                && navigationUpItem.enabled
+                && (navigationUpItem.navigable === undefined || navigationUpItem.navigable)) {
+                navigationUpItem.forceActiveFocus()
+            } else {
+                navigationUpItem.navigationUp(index)
             }
         } else if (navigationParent) {
             navigationParent.navigationUp(index)
@@ -69,11 +69,12 @@ FocusScope {
     function defaultNavigationDown(index) {
         if (navigationDownItem) {
             var item = navigationDownItem
-            while (item && (!item.visible || !item.enabled || !(item.navigable === undefined || item.navigable))) {
-                item = item.navigationDownItem
-            }
-            if (item) {
+            if (item.visible
+                && item.enabled
+                && (item.navigable === undefined || item.navigable)) {
                 item.forceActiveFocus()
+            } else {
+                item.navigationDown(index)
             }
         } else if (navigationParent) {
             navigationParent.navigationDown(index)
@@ -85,11 +86,12 @@ FocusScope {
     function defaultNavigationLeft(index) {
         if (navigationLeftItem) {
             var item = navigationLeftItem
-            while (item && (!item.visible || !item.enabled || !(item.navigable === undefined || item.navigable))) {
-                item = item.navigationLeftItem
-            }
-            if (item) {
+            if (item.visible
+                && item.enabled
+                && (item.navigable === undefined || item.navigable)) {
                 item.forceActiveFocus()
+            } else {
+                item.navigationLeft(index)
             }
         } else if (navigationParent) {
             navigationParent.navigationLeft(index)
@@ -101,11 +103,12 @@ FocusScope {
     function defaultNavigationRight(index) {
         if (navigationRightItem) {
             var item = navigationRightItem
-            while (item && (!item.visible || !item.enabled || !(item.navigable === undefined || item.navigable))) {
-                item = item.navigationRightItem
-            }
-            if (item) {
+            if (item.visible
+                && item.enabled
+                && (item.navigable === undefined || item.navigable)) {
                 item.forceActiveFocus()
+            } else {
+                item.navigationRight(index)
             }
         } else if (navigationParent) {
             navigationParent.navigationRight(index)
@@ -117,11 +120,12 @@ FocusScope {
     function defaultNavigationCancel(index) {
         if (navigationCancelItem) {
             var item = navigationCancelItem
-            while (item && (!item.visible || !item.enabled || !(item.navigable === undefined || item.navigable))) {
-                item = item.navigationCancelItem
-            }
-            if (item) {
+            if (item.visible
+                && item.enabled
+                && (item.navigable === undefined || item.navigable)) {
                 item.forceActiveFocus()
+            } else {
+                item.navigationCancel(index)
             }
         } else if (navigationParent) {
             navigationParent.navigationCancel(index)
-- 
2.17.1



More information about the vlc-devel mailing list