Is input key down in widget issue

I’m having issues detecting whether shift is pressed when I press a button widget.
The following picture shows the simplified blueprint setup in all the following cases, in a widget blueprint, child of user widget.

What happens is that if I start clicking the button, while shift is pressed, it will always return false. If I release shift, press shift again and once again click the button, it returns true.
Reset.
If I click the button once, then shift click it, it returns true. I must have interacted with the button for it to detect the shift press, or something.

So I decided to try the same thing with a border.
Create a border, bind the on mouse button down to a function using create binding and implement the node setup.
Now what happens is that it will detect shift the second time I click. However, if I (while always holding shift) click the button, and then the border again, returns false, but the first click only.
If I click the button, release shift and press shift and click the border, returns true.

So if I alternate between the button and the border, always holding shift, they will always return false.

First I thought it might have been my project, but I recreated it in a newly made template.

Am I still missing something? Is someone able to replicate the issue?
And what alternatives are there?

So I noticed, that if I make a Input Left Shift node setup as below in a player character or player controller, whatever receives input:
Left Shift pr.png

That the moment I press a button widget while holding shift, the ‘Released’ node is triggered.

I don’t know what to think, is it a bug? Intended? Just for me?

To me it seems that when you press a button widget, it can stop keyboard input.
Steps: create a third person template.
Create a widget and add a button to the canvas.
In the character, set input mode game & UI, set show mouser cursor true, create the widget and add it to viewport.
That’s all you need to do to break the input but it will require some steps:

Make the character run forward by holding W. The goal is to have it keep running forward.
If you click on the button widget now, nothing goes wrong.
If you click in the world-space** and then click on the button widget, nothing goes wrong.*
However, if you make any keyboard input before or after clicking the world-space, now clicking the button widget will stop the W input, even though you’re still pressing it.

  • Actually, the input seems to be lost for just a frame
    ** I say world space because I don’t know what to call a ‘non button widget area’. But same problem remains if you click on borders (even if they have a overridden on mouse down function).

Further messing around shows that if you press W+A to run vertically, clicking the button widget (after clicking the world-space), stops input from the first button that was pressed.

Is this a bug or intended? Because I need to be able to press button widgets and not having keyboard input issues. Especially for the shift+clicking of buttons.

I am having the same issue. I want to detect if some keys are being held down when an UMG button is pressed (in my case ctrl), and it does not work always. Any workarounds?

Hello. In my case, the problem had to do with the button getting focus. While The resulting behavior is still strange to me, it is fixed by unchecking the ‘Is Focusable’ checkbox in the details for the button. If this does not fix the issue, please explain in detail the setup you’re using and I may be able to help.

For example, Are you using the buttons *OnClicked * function or OnMouseButtonDown? using the OnMouseButtonDown overridable function with a button, left clicks will be overridden by the buttons OnClicked function, while right mouse buttons will use the *OnMouseButtonDown *function.

2 Likes

This solved the issue in my case, with input mode game and UI I had to disable the is focusable option on all widgets, when focus changes from game to UI (clicking with mouse on UI makes this) the current keyboard input is reset and even if you are holding down a key an is released event is triggered.

1 Like

Hi,

The IsFocusable=false workaround doesn’t seem to work in 4.25.3.

Is there any official way to check whether a key is down while clicking a UI button ?

Thanks
Cedric

You detect both in UMG:

Thank you very much for taking the time to answer :slight_smile:

In the meantime i also asked the question on the answerhub and got a simple working answer there:
https://answers.unrealengine.com/questions/983364/ctrl-button-click.html



const FModifierKeysState modifierKeys = FSlateApplication::Get().GetModifierKeys();
if (modifierKeys.IsLeftControlDown())

So there are ways to make this work :slight_smile:

Thanks
Cedric

In 4.25.3 worked for me. Make sure you set the root element of the UI.

The IsFocusable=false set on the Button worked for me!