Comment 4 for bug 1513897

Revision history for this message
Andrea Bernabei (faenil) wrote :

I spent some time debugging this, I'll leave my findings here:

Situation in 1.2
TextField has both
"activeFocusOnPress: true" AND "property alias activeFocusOnPress: editor.activeFocusOnPress" (I don't know the reason behind the choice of having a property alias with the same name as the property coming from the C++ StyledItem)
and editor, which is a TextInput, has "activeFocusOnPress: true"

What happens in 1.2 when you tap on the button?
TextField doesn't get the focus, because its activeFocusOnPress is never set to true.
In fact, because of the alias declaration, setting "activeFocusOnPress: true" just enables the property of the editor, and doesn't actually change the property of the TextField (this is my guess after debugging the focus logic).
As a consequence, commenting out "activeFocusOnPress: true" in 1.2 TextField doesn't bring any behaviour change, because TextInput's activeFocusOnPress is true by default.

Situation in the current 1.3 (I'm testing on r1688)
The property alias was removed from TextField (this can be considered a fix). As a consequence,
"activeFocusOnPress: true" has the intended behaviour of setting the property of the TextField to true.

What happens in 1.3 when you tap on the button?
TextField gets the focus, because it has activeFocusOnPress set to true, so due to the way the current focus logic works, when the Button gets a mouse event, its parents get focus (if they requested it).
So even if UCAbstractButton has activeFocusOnPress set to false, its parent, TextField, still has it set to true, so it will get the focus whenever the Button receives a click.