← Back to team overview

ubuntu-phone team mailing list archive

Toolkit: focus handling on components

 

Hello All,

We have released recently a bug fix which makes possible for a styled
component to grab the focus on mouse press or when touched. By default the
behaviour is turned off on s StyledItem, but in most of the active toolkit
components is turned on (buttons, list items, popups, pickers). Whereas in
most of the cases this is harmful for you, there can be situation when the
focus grabbing on a Button or Checkbox is not desired. This can be achieved
by setting the activeFocusOnPress to false for the component.

As said, the focus handling has been introduced on StyledItem, therefore it
good to read the documentation once the website gets updated [1].

Meanwhile the idea: "activeFocusOnPress" (default false) drives the focus
grabbing on a component, and a component can grab focus only if all its
StyledItem ancestors are having this property true.

Popups are a special case: their element safe grabbing the focus when
tapped as well. However, when closed, the focus is restored to the
component being focused before the popup got opened. In case this is not
desired, the focus can be set to any other component by watching the time
the popup is closed (yet needs to be connected to popup's
Component.onDestruction signal) and then setting the focus to the desired
component. And here comes the second API: requestFocus() function is the
preferred one to be used. You can use forceActiveFocus() as well, however
that one doesn't check the ancestry, like requestFocus() does.

And last but not least, for any questions, ping us on #ubuntu-app-devel, or
write us.

Cheers,
Zsombor

[1]
http://developer.ubuntu.com/api/qml/sdk-14.10/Ubuntu.Components.StyledItem/

Follow ups