[Qt-components] Key navigation

Alan Alpert 416365416c at gmail.com
Tue Jan 8 16:00:10 CET 2013


On Mon, Jan 7, 2013 at 11:22 PM, Alberto Mardegan
<mardy at users.sourceforge.net> wrote:
> On 01/07/2013 09:02 PM, Alan Alpert wrote:
>> But presumably the root object in a Button component is a FocusScope,
>> whereas that of a Label would not be. So that's how you automatically
>> know which ones are focusable and which aren't, by the type of the
>> root object.
>
> I don't see why the Button should be a FocusScope. That probably doesn't
> harm, but what is the advantage of declaring as a FocusScope an item
> which doesn't have at least two focusable child items?
>
>> http://qt-project.org/doc/qt-5.0/qtquick/qtquick-input-focus.html
>> makes it look like any focusable component without a FocusScope is
>> going to be acting funny anyways.
>
> Maybe I read it carelessly, but I didn't find any hints there; what part
> are you exactly referring to?

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.

--
Alan Alpert



More information about the Qt-components mailing list