Tab key for UI widget ( adding and removing from viewport)

Does anybody know why creating a widget on the viewport with Tab works fine but if you try to close it again (FlipFlop) it won’t work while using some other key like E for instance it does just fine. I am setting the input mode to game and UI when adding it and game only when removing it.

I have a work around using OnkeyDown override in the widget but just curious why this is happening in case I can avoid having to do that in the widget.

It’s hard to tell your problem from the given information, but if it works as expected when hard-coded with E, but not with a flip flop, that likely means you’re incorrectly using said flip-flop.

If that’s not the case, please provide more descriptors and preferably some images of the UI and the Input/Flipflop as well.

It’s pretty simple the Tab is not working like it does E for instance. Flip Flop is very basic. You enter once it flips and you enter the second time it flops. It seems the Tab is not being registered once the UI is open. If I use the tab inside the widget as I explained I can.

I have even tested just now using E to create the widget and Tab to remove it and it doesn’t work but the other way around it does. Flipflop was out of the equation so it has nothing to do with it.

I did an even simpler test of adding a print string right next to the tab and it only prints when creating the widget. When I try to remove the widget by pressing Tab again it doesn’t even print anything.

I think it is because tab is overridden by the widget, as it is used to navigate focus between elements within the widget.

The best way is to view your node flow. Try pressing the tab key during gameplay and obsereve your nodes at the same time and see whether your TAB key node executes or not. If it does then, it’s obvious that your condition is the problem.

Still not work? Then my guess is your focus is not on your viewport. You can use this node to always makes your focus to be on your viewport back as the tab key event executed.

I am working on a new different inventory now and the tab works fine. I will have to dig on the other one a bit more just to understand what was causing that. Will report back when I have the time. Just to reply to your comment I tested by adding a print string node right after the tab input and it did nothing once the widget was open. So the first key down it prints but the second time once the UI was open did not print at all. Using the node you mentioned didn’t change anything.

Ok it seems the fix is by clicking once on the screen when the mouse cursor appears the first time. This is only needed when using tab. Using E it doesn’t happen. Very weird to be honest because it happens only the first time you launch the UI. Once it’s open it won’t require you to click again. I think the best practice would be creating the widget on begin play and just play with it’s visibility. I think the problem comes from creating the widget when using the key. Weird thing is that it doesn’t happen using E.

Posting an image of the nodes just in case.

So yeah I just did that and instead I am creating the widget on begin play and now tab works just fine using the flipflop to set it’s visibility. It looks much better too. :slight_smile: