I’m trying to toggle a 3d menu on/off, using enhanced input action with TAB key.
Problem is, once the widget is up, when I try to close the widget, TAB starts cycling through my buttons instead of closing the widget, like I tell it to.
How do you solve this issue?
The Tab key is unfortunately hardcoded for UI navigation purposes and I highly recommend you to avoid using it, probably isn’t getting fixed any time soon. If you really need that exact key, either research FNavigationConfig::GetNavigationDirectionFromKey
and see if you can unhardcode it for your use case, or use a modifier (see implementation, the Tab isn’t consumed if certain modifiers are pressed).
Oh boy. TAB is one of the most prevalent keys when it comes to opening/closing menus in video games. I’m not a programmer, I don’t think I can dive into C++. Thanks for the reply.
If the input focus shifts from the game to the menu, it is necessary to redirect the focus back to the game. Depending on your specific requirements, I recommend disabling all focus elements on the menu prevent it from focus. In UMG, this can be achieved by disabling the “Is Focusable” property.
Disabling focus on ALL widgets will prevent any sort of keyboard/gamepad navigation for the UI, so it would really need to be a very niche use case where this is warranted over just changing the Tab binding.
I tried removing focus on all elements of the widget, but since it’s interactable, I think it regains focus when I click on any of its elements. So then TAB still doesn’t work.
I know, but this is one of those things that can’t just be circumvented, because it matters a lot from a gameplay perspective. The player needs to be able to bind to any key they want. This is like a non negotiable.
- There is probably still a focusable widget somewhere in the hierarchy.
- Working “against” the engine without using C++ is basically impossible, even if you make it work with the current set up you’re bound to end up in the same situation with every future widget. And if any widget in the future actually requires focus (or a similar functionality) you’ll have to undo ALL of it or implement ALL of it yourself in BPs.
- To make sure we’re on the same page I’ll reiterate - you’re emphasizing the need for keyboard bindings, and at the same time disabling one of the main keyboard features related to UI, which is keyboard navigation.