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.
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?
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.
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.
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.