Disabled widget can still be operated with keyboard

I have a widget that creates another widget on top of it (a simple Yes-No window). When this Yes-No widget is added to viewport, the main widget is disabled, so I can’t click its buttons with a mouse; however, I can still select and activate the main widget controls with the keyboard and/or gamepad.

I tried various combinations of ZOrder, SetInputModeUIOnly with focus on the Yes-No widget, SetFocus, SetUserFocus, and SetKeyboardFocus, but the main widget is still accessible by keyboard, and it additionally disrupts the operation of the Yes-No widget, since I can’t set keyboard focus on Yes and No buttons – focus jumps to the main widget.

So how can I make the keyboard/controller actions be bound to only one widget?

Thank you!

Hey Tuerer, good question,

Have you tried setting isFocusable to false on the main widget when creating the child widget? Then when clicking either button on the child, just add a node to change isFocusable back to true on the parent. Keep in mind you may not need separate widgets for something like this; you can keep all this logic in one widget by manipulating visibility of different widget elements. A yes/no box can just be two buttons and a background which are set to visible when another part of your widget is clicked.

Good luck!

Thank you for replying, @anon58774453.
Setting bIsFocusable to false doesn’t help either.
And the confirmation window is used in multiple places by various widgets, so having it as a separate widget is the preferred way for me.
For now I’m setting the underlying widget visibility to collapsed when I create the confirmation widget, and it works okay, so if I don’t find the option to leave it visible, this will be the workflow.
I have to check it in UE5, maybe something was updated there.

You can add a full-screen backdrop in the confirmation pop-up (invisible, or with a blur, or with a shade, or both), make it focusable, and it should eat all the events, preventing any interaction with the main widget behind.

Tried that, doesn’t work. If any, it only adds one more element for the keyboard focus to jump to.

Hmm you are right I was only thinking about mouse clicks.

You can control keyboard navigation behavior a bit with the properties in the Navigation tab in your widget. By default they are set to Escape, which allows navigation to leave container and go all over the place :slight_smile:

image

I believe what you want for your case (a popup) is set them all to Wrap, so it will just cycle Yes and No buttons and never leave container. In my case I wasn’t able to modify those values on the widget designer for some obscure reason, however this worked :

image

2 Likes

Hmm, thank you, this kind of works in terms that the selection does not leave the widget bounds once within; however, the issue of getting into the bounds in the first place pertains.

I’ve tried SetFocus(), SetUserFocus(), SetKeyboardFocus(), even set input to UI only with focus on the newly created widget, and on either of the buttons within this widget, but if there are numerous controls under it, it’s still quite tricky to get into the bounds, no matter what ZOrder of widgets are.

Is there maybe any other way to force selection of a certain element besides the above?