[Qt-components] Key navigation

Alan Alpert 416365416c at gmail.com
Wed Jan 30 18:15:57 CET 2013


On Wed, Jan 30, 2013 at 3:33 AM, Alberto Mardegan
<mardy at users.sourceforge.net> wrote:
> On 01/29/2013 10:51 PM, Alan Alpert wrote:
>>
>> If we want to avoid mixing up meanings, we shouldn't be placing this
>> on the Item at all. There should be a separate attached property like
>> KeyNavigation.inFocusChain for this specific feature of focus chains
>> to split it out.  [...]
>
>
> +1 for KeyNavigation.inFocusChain
>
>
>> If we're just focusing on the desktop components, I'm starting to like
>> your initial FocusChain{} item more. You can even get the convenient
>> syntax just by having your own Item subclass for key-handling - have
>> you considered that?> The component set, for a keyboard enabled
>> platform, could have a "FocusScope subclass" like KeyContainer which
>> handles key navigation with a FocusChain attached property. It's a
>> similar approach to adding more functionality to KeyNavigation, except
>> that since it's on the component set level you can do whatever you
>> want without worrying about backwards compatibility.
>
>
> Do you mean that instead of writing
>
> ============
> FocusScope {
>
>   FocusChain {
>     id: focusChain
>     rootItem: widgetContainer
>   }
>   Grid {
>     id: widgetContainer
>     ...grid properties...
>
>     Keys.onTabPressed: focusChain.focusNext(Qt.Key_Tab)
>     Keys.onBacktabPressed: focusChain.focusNext(Qt.Key_Backtab)
>
>     Button { ... }
>     ComboBox { ... }
>     ...other widgets...
>   }
> }
> ===========
>
> one could just write:
>
> ============
> KeyContainer {
>
>   Grid {
>     id: widgetContainer
>     ...grid properties...
>
>     Button { ... }
>     ComboBox { ... }
>     ...other widgets...
> }
> ===========
>
> ? If so, then no, I didn't think about that -- and indeed I like the second
> solution much better (I'm still wondering if there are cases where the
> flexibility of a separate FocusChain would be beneficial, but I cannot think
> of any concrete example right now).

Actually, I meant something more like
============
  Grid {
    id: controlContainer
    ...grid properties...
    Button { ... }
    ComboBox { ... }
   ...other controls...
}
===========
Where Button and ComboBox both have a KeyContainer as their root items
(replacing the FocusScope). KeyContainer would be implemented in C++,
be a focus scope, and have a tabOrder property.

--
Alan Alpert



More information about the Qt-components mailing list