How to only interact with HUD (canvas) using muse

Hi, i am making a GUI/HUD interface using canvas. I have set up so when i press Z i will put:
ShowMouseCursor = true ,
EnableMouseOverEvents = true ,
EnableClickEvents = true

When i do this, i can see my cursor and move my mouse, but also my character keep looking around when i move my mouse until i left click once ( then the character wont be affected by the mouse movement).

How do i fix so i do not have to left click every time i enter mouse mode?

Oh sry, thought i posted this in C++ Programming ( i moved it from Blueprint to C++ section)
But what i do is when Z is pressed i just enable ShowMouseCursor, EnableMouseOverEvents and EnableClickEvents.
Feels like i need to disable “character look around” or something like that.

Hi ,

Could you post an image of your blueprints so we can get a better idea of what you have and what may help you?

Hi ,

Have you tried putting your camera movement controls inside an if statement that checks to see if the mouse cursor is not currently visible?

Some pseudocode:

bool MouseStatus = false;   // Indicates whether or not the mouse cursor is currently visible

void CameraMovement()
{
   if (!MouseStatus)
   {
      // Handle camera movement based on mouse input.
   }
}

void ActivateCursor()
{
   if (MouseStatus)
   {
      // Hide mouse cursor and disable mouseover and click events.
   }
   else
   {
      // Show mouse cursor and enable mouseover and click events.
   }
   MouseStatus = !MouseStatus;
}

Another possibility is to use IgnoreLookInput in the PlayerController. You can access this by using IsLookInputIgnored() and SetIgnoreLookInput(). I have not actually used this option, but the documentation seems rather straight-forward. If you want to use this option and run into any problems, please let us know.

Hi!
I got the ignore look to work now, but i still have to click one time with mouse to change some kind of focus.

If i press the action key to change to mouse mode and then i press the action key again, the mouse cursor is gone and i enable look input again and such. But i still have to perform one left click with mouse to be able to look around.

Hey ,

I’m cleaning up old unsolved issues. Are you still having problems with this?

Still having this issue. I need to click left mouse button once to be able to interact with my GUI. Same thing when i return to game from GUI.

Hey -

Which version of the engine did you first encounter this issue on and which version are you working in now? Have you noticed the same behavior through each version of the engine you’ve worked in?

All versions I’ve used so far. Atm i am working with 4.6.1.

Hey -

If you are using the engine built from source you can find a method called “SetInputMode_GameAndUI” inside the WidgetBlueprintLibrary.cpp file. This node (when used in blueprints) will free the mouse from the game menu and allow you to move it around. You should be able to call this method in code to get the same result. You’ll want to make sure you set bHideCursorDuringCapture to false. The same goes for bLockMouseToViewport if you want the mouse to be able to extend past the game border to click on another program.

Cheers

Still doesn’t solve the left click before i can interact with my UI.
For example, if i bind SetInputMode_GameAndUI on key Press Z. I got an UI button that will print out “Hello” when i press it.
When i press Z i can indeed see my mouse and move it around but it wont react to my -first- Left Click. After the first left click i can now press the button and i see my “Hello” message.

Hey -

How are you implementing your UI? Is it being setup with UMG or are you doing it inside the code? If you are indeed using code for your UI could you post the code that creates the UI?

I changed to UMG but the problem remain.

Hey -

Sorry for the delayed response, I am still investigating the best way to overcome the first click not being registered when trying to use the UI (though code). Just as a check in the level blueprint could you add the following test setup.

Create a Keypress event (U key for example) and the “Get player controller” node. From the player controller node create a “Set Show Mouse Cursor” and wire that into the event. Again from the player controller node add a “Set Input Mode Game and UI” node and wire that into the Set node. Then create an event node for “Event Begin Play” and wire that into a “Create Widget” node. Set the class of the create widget to the widget blueprint you’re using. From the return value add an “Add to Viewport” node and make sure the execution pin is wired back into the create widget.

Now when you test the game in the editor you should be able to press the key (U) to have the mouse appear in the game window and clicking on the button should interact with it on the first click. Let me know if this is the same behavior you experience or if you get different results.

I just tried out the 4.7.0 Preview build 4 and it seems to work now. The first click does indeed get registered right away now :slight_smile:

Thanks, .

Set Input Mode Game and UI worked for me! I’m using v4.7.

Here a screen shot if some people are still having trouble. My menu works on a flip/flop so I need the second game only node to get back to actually playing after closing the menu.