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"

How to make HUD ignore mouse?

In my game, the player walks around using the mouse and can type text using the keyboard. I've got a UMG with a text field that accepts keyboard input. There are no other interactive elements in my widget, and I don't need to use the mouse cursor to switch between anything.

When I use Set Input Mode Game and UI, I lose control of the game character, and moving the mouse no longer controls it. I'm already setting focus on my text field manually, so I would really prefer the UMG to just ignore all mouse input altogether.

To be more precise, I want to achieve the following result:

  • Keyboard input in the widget gets enabled

  • Mouse input stays with my character

  • Focus on the text field for the keyboard

  • Cursor stays invisible

Is it possible to do this?

Also, the cursor doesn't disappear even though I have Hide Cursor During Capture enabled.


Product Version: UE 4.8 Preview
more ▼

asked May 15 '15 at 03:03 PM in Using UE4

avatar image

228 4 11 17

avatar image krides May 15 '15 at 03:55 PM

It turns out that using the Set Input Mode Game and UI is harmful in my case. By removing it, I've managed to achieve the expected result. I just connect to the Set Keyboard Focus node.

Now, my problem is that as soon as I press any button, I lose focus. If I try to do Set Keyboard Focus every frame, my text gets committed automatically as soon as I press anything. Is there any way to avoid this?

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

1 answer: sort voted first

Hi krides,

This is a bit tricky to find out but I found a simple way to do it. I'm not sure what way you're using to get the UMG to appear or if it is persistent, but in my example I'll be using T to spawn it, and Enter to make commit changes and make it go away.

First we set up the PlayerController blueprint to activate the widget. I first add a 'T' event and link it to CreateWidget and Add to Viewport node so that it'll spawn the textbox when I press T. I then add the Set Keyboard Focus and set the reference so that it'll let the keyboard enter input to the widget instead of the PlayerController once it is spawned.

alt text

Then we set up the widget. I made a 3D widget blueprint with a text box and a few letters for default text. I then added 'OnTextCommitted' as a function to the event graph. I set it to give input of the game back to the controller and then remove the widget.

alt text

I hope this is able to help!

Matthew Clark

pcbp.png (107.6 kB)
widget.png (71.4 kB)
more ▼

answered May 15 '15 at 05:19 PM

avatar image krides May 15 '15 at 05:27 PM

I'm doing something very similar, and text gets committed every time I press any button, including mouse buttons that are assigned to movement and Esc which is supposed to open the in-game menu. Does this happen to you?

Another thing that I haven't mentioned is that I'm using a 3D widget within a blueprint. I set focus, just like you do in your example, but when entering a trigger. If you press "T" while walking, does your character stop? It happens to me, even though I move the character with Left Mouse Button and not touching the keyboard at all.

avatar image Matthew J May 15 '15 at 06:09 PM

The way it works for me, if I press T, the only way to exit the text box is to commit by pressing enter or by pressing escape. If the text box is up, my mouse will turn the camera as it usually would but I cannot move as the WASD keys are inputting into the text box. I'm not sure how it would work when moving the character with the left mouse button, as I did my example using a blank project with default pawn movement.

avatar image krides May 16 '15 at 11:21 AM

Alright. I've just tested, and yes, it would appear that the function Set Keyboard Focus ignores the last input, be it mouse or keyboard. Should I report this as a bug?

avatar image Matthew J May 18 '15 at 01:38 PM

I apologize but I don't exactly understand what you mean. Can you give me an example as to what input Set Keyboard Focus is ignoring?

avatar image krides May 18 '15 at 01:56 PM

I set movement forward control to LMB. When I enter a trigger I use the Set Keyboard Focus in 3D widget on a text field. The focus gets set for the keyboard, but in the meantime my character stops walking, as if I stopped pressing LMB, which I didn't. To make the character move again, I am forced to release LMB and press it again.

avatar image Matthew J May 18 '15 at 02:25 PM

Thank you for the example. No need to put in a bug report as I went ahead and reported the issue in our system for you. For your reference, the bug number is UE-15753. I will say that this may just be the way things are designed but it is possible that it may be fixed. I wish I could offer a workaround for the time being but I can't think of any.

avatar image krides May 18 '15 at 02:30 PM

I have already found a workaround: I use Set Keyboard Focus once on begin play and deactivate input by saving and erasing input in the text field OnTextChanged. I just thought I'd let you know about this problem I had because to me it seems counterintuitive that a function called Set Keyboard Focus affects mouse input. Thanks for all the help!

(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