UI Toolkit: Focus and Hover button states

Hi!
I am building my game’s runtime ui using UI Toolkit in Unity (version: 6000.0.29f1). UI Toolkit automatically detects navigation inputs and toggles the focus state of my buttons if the ‘Focusable’ attribute is enabled on the buttons. Now my problem is that when I hover my mouse on a button AND I use the navigation keys, two buttons can be highlighted (one from the cursor hover and the other one focused from the input). My question is, is there a built-in function in UI Toolkit to prevent these (in my opinion) inconsistent states I do not know about, or should I handle this scenario manually?

Thank you for your replies in advance!

Hello! you can be hovered on one button while focused on another, that’s completely fine. Even with the mouse alone, that’s possible.

Here the width field is focused while I hover over the height field.

If you’re bothered by the styling, you can edit it by creating selectors that target the field as its hovered or focused and unset the border color or text color:

.unity-button:hover { }

2 Likes

All right. Thanks for the answer.