[Interest] QtQuick - How to move focus away from disabled Item?
Nate Rogers
bob119er at yahoo.com
Thu Jan 29 14:45:28 CET 2015
I would do it externally from the buttons themselves on the event that causes the permissions to change. On the event you could first loop through to find the button with the active focus and if it is no longer enabled then you could loop through each button to find one that is and set it's focus to true. Or even easier would be on the event just set the focus to a button that is always enabled like your menu button or whatever.
For example:
Connections{ target: parent onUserPermissionChanged: // Or whatever the signal is that is changing your button's enabled state {
menuButton.focus = true
}
}
Nate
On Wednesday, January 28, 2015 4:50 PM, Ola Røer Thorsen <ola at silentwings.no> wrote:
Hi Jerome, thanks!
Yes I know about the FocusScope item and how it works. The specific issue is the one I explained in my previous email, and I'm looking for a workaround. FocusScope doues not move focus to another item if the current focus item is disabled.
Cheers,Ola
2015-01-28 18:04 GMT+01:00 Jérôme Godbout <jerome at bodycad.com>:
Hi,This may not be a direct answer but you may want to take a look at FocusScope Qml Element:http://doc.qt.io/qt-5/qml-qtquick-focusscope.html
Here's a good explaination about those scope:http://doc.qt.io/qt-5/qtquick-input-focus.html
Hope this help somehow,Jerome
On Wed, Jan 28, 2015 at 9:46 AM, Ola Røer Thorsen <ola at silentwings.no> wrote:
Hi,
I'm having some trouble making a robust QtQuick 5.4-based application where I only have 4 cursor keys and a return key available as the input method for the user.
I have various gui buttons that I can move focus between. I've set this up using the KeyNavigation.onXXX etc. For a simple static gui, this is fine.
However I get into trouble once some buttons get disabled (enabled-property set to false). This is done based on external events, so it may happen at any time.
If a button with active focus is disabled, I'm stuck. The button's focus property is still true, but it will not receive key events, so I cannot move focus to the next using the cursor keys. I'd like focus to move on to some other item automatically anyway.
Have any of you got some recommended way of dealing with situations like this?
I think I've spent half the development time on this application just making sure keyboard navigation cannot get stuck.
I did not have such issues when creating similar applications with Qt Widgets. There the behavior is that focus moves on to another widget automatically if I call setEnabled(false) on a widget with current active focus.
I've tried doing something like this in my Button item:
Button {
id: button
activeFocusOnTab: true
function transferFocus() {
if(!visible || enabled)
return;
if(nextItemInFocusChain() === button)
return;
if(focus)
nextItemInFocusChain().focus = true;
}
onEnabledChanged: transferFocus()
}
This works OK in a smaller test application, but makes the larger application hang when "nextItemInFocusChain" is called for the 20th time or so.
Cheers,
Ola
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150129/a3228684/attachment.html>
More information about the Interest
mailing list