Hello, I am trying to use UIToolkit to build a dynamic menu and I am trying to understand why pressing tab navigates in the menu. As I understood it, with Input System, the input events come from the default UI action map and I can’t find tab being used in there so why is tab doing stuff. So, where is the tab input coming from?
Hello! Tab triggers the NavigationMove event, in the direction of Next. You could try listening for that and stopping propagation to prevent any action.
Hi Laila,
alright thank you. Small follow up, is there a way to synthesize a Next NavigationMove event so that I could get the same behaviour but with something like down arrow?
That is covered in the docs: Unity - Manual: Synthesize and send events
Is it? Could you describe it more detailed?
What part of the docs don’t you understand? I’d just be repeating what the manual shows.
The down arrow also triggers a NavigationMove event, in the Down direction, you could listen for that, and change selection, not sure which dropdown menu you’re using, but assuming you have access to changing selection.
Thanks for the answers! I still don’t understand how to synthesize a NavigationMove event with direction Next. I’ve tried running the Synthesize method with KeyCode.Tab but my menu does not receive it. What is so special about tab?
Can I change tab to be arrow up and down instead?
Do I have to make all of the navigation by myself as you suggest Laila?
Oh, managed now with the following
using(NavigationMoveEvent navEvent = NavigationMoveEvent.GetPooled(NavigationMoveEvent.Direction.Next))
{
doc.rootVisualElement.SendEvent(navEvent);
}