Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Product Version: UE 4.16
more ▼

asked Jul 05 '17 at 06:15 PM in Blueprint Scripting

avatar image

55 3 9 15

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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

UI example: https://gyazo.com/e545a1d79d579652166dd959b0231118

more ▼

answered Jul 06 '17 at 01:20 AM

avatar image

7k 143 28 172

avatar image Allshar Jul 06 '17 at 10:07 AM

Thanks for help. What I was doing wrong was the event reply in widgets. I was using "make" node (like for structures) and that is empty, didn't notice there where other options.

avatar image Allshar Jul 06 '17 at 11:20 AM

For the purpose of debugging, since that only fixed part of my problem... Is there a way to know what consumed an input? alt text I have this. As simple as it gets. Press event doesn't trigger most of the time. Sometimes it does, not it appears completely random. So, something has to consume that input. but I have no idea what. Whats even more weird is that clicking fast works, while clicking slowly, either by holding the button down for longer or by having a longer delay doesn't.

capture.png (48.6 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Jul 06 '17 at 11:44 AM

avatar image

55 3 9 15

avatar image javoire Oct 18 '17 at 11:29 AM

That's interesting! Your comment fixed my issue. Thanks!

Basically I have a RTS setup where I drag the map by holding down right mouse button.

With the "input mode to game only" set and cursor shown, the "pressed" event of the mouse is only caught once and never again.

With hidden cursor, the mouse presses are registered as normal.

I assume in the former case the there's some unexpected behavior with the event bubbling getting caught (handled) in a place I wouldn't expect or such.

I'm still quite new to UE4 but this behavior seems to me as not desirable :)

avatar image javoire Oct 18 '17 at 11:35 AM

Hmm not really. Clicking left mouse button while input is "game mode" re-introduces the right clicks not being registered anymore. Perhaps I need to go a completely different route for my "drag scroll" implementation..

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question