UI input / input mode
So, I have been fighting with input modes for game / UI, and I'm stuck. I used some weird workarounds, but I need a clear solution.
Can I make it so that UI consumes everything mouse related, while player controller still consumes keyboard? So, dragging and clicking in UI, keyboard in the player controller.
With input mode set to Game and UI:
If I use any custom widget and use "OnMouseButtonDown" and "OnMouseButtonUp" the "up" function doesn't trigger. Simple mouse click events in player controller also appear to randomly lose input. How exactly does "capture" work and can I disable it without losing keyboard input?
With input mode set to UI Only:
I can use key events in the player controller (to close the UI for example). In that case "OnKeyDown" inside the widget works only in some cases. It doesn't work for some widgets and I can't figure out why. That is also a problematic solution since there are many widgets some nested inside each other and I would have to use that function in every single one of them.
Alternatively, is there a way to get player input before player controller gets it and starts applying it's own weird rules?
Thanks for help
asked Jul 05 '17 at 06:15 PM in Blueprint Scripting
First off I encurage you to read the tooltips on the functions. They reveal suttle Details ;P in most cases enough to figure out whats going on. (Some apply only under certain conditions!)
You have to understand there is a Priority who recives Input first or even not at all. Thats what the Input Mode is there for. (tooltip again reveals the order)
Next you have to understand that Input can be Consumed and what Bubbeling means. Each Input gets passed to someone (Controller, Character, Widgets etc.) and the one who recives the Input can decide if he wants to Consume it or not. If you Consume the input (or Handle it) that means we are done with the Input nobody else needs to recive it.
If however you decide to not Consume it (leave it Unhandled) you let the Input pass to the next one in the Priority line to recive it. That is called Bubbeling.
If you rember those Important things you should have no trouble in most cases except some Edge cases. (Third Person Click and Hold Mouse from the PlayerController for example can prevent the MouseUp event to fire in the UI)
For most UI related Events keep in mind that the Widget has to have User Focus in most cases. Since the Input System has to know to what UI we want to send the Input. You can different UI respond to the same Key but each one can do something completly different with it. Thats why we need the Focus =)
Input Event Example: https://gyazo.com/243253e22606d55d7a57c50c5a320a4a
Ok. I found the source of my problem. I had "show mouse cursor" set to true, and Input mode to game only. It didn't seem like something that could cause problems, but it did.
answered Jul 06 '17 at 11:44 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here