Jump to content

Question: How does UI focus work


Recommended Posts

I tried to make my mod's ui screen support arrow keys, something really strange happens.

image.thumb.png.e313de0eecb5f86fc064e15628cbec89.png

When I tried to press down here(The focus is on elite class), the focus doesn't move. I can navigate my focus freely across everything at the top, but not below.

(Okay, now I figured that only the top buttons inherited the Widget.Clickable class, but not the tracks down the bottom. That would probably be why it didn't work. Still, I am not sure how everything here works, so I'm asking this question anyway.)

Anyway, is there a way to show tooltip on focus as well instead of on hover? Thanks

Link to comment
Share on other sites

  • Developer

Typically focus will only be applied to Widgets for which can_focus = true.  There is another field called show_tooltip_on_focus, which if true will enable tooltips for that Widget if it has focus.

You can explicitly assign a directional focus mapping using Widget:SetFocusDir.  If the user tries to advance focus in a direction for which there is no explicit mapping, there is a default algorithm that tries to find a reasonable target (which is probably the behaviour you're seeing.)

That behaviour does a tree search from the current focus by first traversing its children, in order, and then exploring its parent.  This is done recursively, but it avoids searching past any Widget which is not focusable.  Of the valid candidates, the closest one in the proper direction will be preferred.  That's roughly how it works in a nutshell, and is meant to "mostly work" how you'd expect, but of course depending on how things are laid out, may not be what you want.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...