[Qt-components] Key navigation
Alberto Mardegan
mardy at users.sourceforge.net
Tue Jan 8 16:47:10 CET 2013
On 01/08/2013 04:00 PM, Alan Alpert wrote:
> http://qt-project.org/doc/qt-5.0/qtquick/qtquick-input-focus.html#acquiring-focus-and-focus-scopes
>
> It shows a component that is practically a button. It too has only one
> focusable item. But when used as a component, the two objects with
> "focus: true" lead to a confusing result in the main file. I assume
> the same would happen with Button:
>
> Button { id: button1; focus: true }
> Button { id: button2: }
>
> So without a FocusScope on button, you just end up with two MouseAreas
> with focus == true and the 2nd button is likely to start with the
> keyboard focus.
I see. The way that keyboard focus is handled in QML is actually very
confusing; in practice, the "focus: true" property acts both as a
"canFocus: true" flag and as a "setFocus()" method.
The problem in the example above only occurs if the "Button" component
implementation has a "focus: true" property; otherwise, it works fine.
So, following your initial suggestion, I understand that we don't need a
"canFocus" property because a focusable item is either a FocusScope or
an item with "focus" set to "true". Correct?
Ciao,
Alberto
More information about the Qt-components
mailing list