[vlc-commits] qml: recursively traverse disabled NavigableFocusScope
Pierre Lamot
git at videolan.org
Thu Feb 13 11:06:43 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Tue Feb 4 10:15:55 2020 +0100| [79da4a62eb6185d4a4f5b667edf5aac66c4d83b4] | committer: Jean-Baptiste Kempf
qml: recursively traverse disabled NavigableFocusScope
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)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=79da4a62eb6185d4a4f5b667edf5aac66c4d83b4
---
modules/gui/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)
More information about the vlc-commits
mailing list