diff --git a/modules/gui/qt/widgets/native/navigation_attached.cpp b/modules/gui/qt/widgets/native/navigation_attached.cpp index 1b5a74b262..7e04032a88 100644 --- a/modules/gui/qt/widgets/native/navigation_attached.cpp +++ b/modules/gui/qt/widgets/native/navigation_attached.cpp @@ -36,9 +36,16 @@ void NavigationAttached::defaultNavigationGeneric(QJSValue& jsCallback, QQuickIt Qt::FocusReason reason) { if (jsCallback.isCallable()) { - jsCallback.call(); + const auto ret = jsCallback.call(); + + // if the function returns nothing or true, the action has been handled, stop the traversal + // if the function returns a false explictly, continue traversal + if (!ret.isBool() || ret.toBool()) + return; } - else if (directionItem) + + + if (directionItem) { NavigationAttached* nextItem = qobject_cast(qmlAttachedPropertiesObject(directionItem)); if (directionItem->isVisible()