When I press a GUI button with the mouse, key release events stop firing.

I have a project where I’m using arrow keys to rotate a model. I have some buttons on the screen that toggle some things which the user can click at any time since the mouse is always free to move around. When I click a button, then try to press my keyboard keys to rotate the model, the key release events don’t fire, causing my model to start spinning freely. Here’s what my GUI looks like:

I can get the release events to start firing again by clicking anywhere on the screen except on a button.

Hello janimationd,

I have a few questions that will help narrow down what issue it is that you are experiencing.

Quick questions:

  1. Can you reproduce this issue in a clean project?
  2. If so, could your provide a detailed set of steps to reproduce this issue on our end?
  3. Could you provide screen shots of any blueprints that may be involved in this issue?
  4. Are you setting the input to UI only at any point?

So first off I realized it was not generating pressed events, rather than released events.

  1. Yes
  2. Make more than one button in a widget blueprint, put arrow key based key events on something else in the scene, press one of your gui buttons, and then using the arrow keys won’t generate “pressed” events for your object in the scene.
  3. Sure:

  1. No

So upon closer examination I realized what is going on. When I press a button on the UI, it goes into a selection mode which makes pressing the arrow keys highlight buttons rather than execute “pressed” events in game (you can see a white border around one of the buttons in the screenshot). I assume this is intended behavior in screens where everything is a button like on a pause menu, but for my application I need the user to be able to interact with the scene and use the buttons in a way that’s responsive. Is there some way to disable this behavior on the buttons?

Hello janimationd,

If you would like to turn this feature off you can open up the interaction section for the button and uncheck “IsFocusable”. I hope that this helps.

Make it a great day

1 Like

Disabling that option only makes it so the buttons are no longer highlighted, which only means that I can no longer navigate between them with the arrow keys and press enter to activate them. Even when I have the option disabled on all of my buttons, the buttons still gobble up the key press events from my arrow keys.

Hello janimationd,

Have you tried using the on key down override within UMG?

I have not tried, I’ve never used the overrides before. I can do some research into how they work if that’s the only way to fix this, but doesn’t it seem like unintended functionality if I deselect “Is Focusable” and the button still reroutes focus from the main game window?

Hello janimationd,

The reason I made the suggestion above is because I believe that the widget is taking the input focus. By using the widgets on key down override this will allow you to use your inputs even when the widget has focus. You could also play around with setting the input modes to try and achieve your desired result.

Make it a great day

As it turns out, the widget itself has a “Supports Keyboard Focus” option, which when disabled solves my problem. Woo!

Hi where did you find Supports Keyboard Focus for the widget

There appears to be a field of each widget named appropriately in C++ code, SWidget::SupportsKeyboardFocus | Unreal Engine Documentation

So, basically we need to have a C++ component to get this widget (maybe in HUD) and set those functions in it, correct ? @janimationd