[Qt-components] Key navigation

Alberto Mardegan mardy at users.sourceforge.net
Wed Jan 30 12:33:15 CET 2013


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).

Ciao,
   Alberto



More information about the Qt-components mailing list