UI buttons become inactive after clicking world

In my game, the player cannot see the mouse cursor and input mode is game only by default. (Mouse movement input is used to look around).

Once the player holds RMB, the cursor is shown to the player, the input mode is switched to game and UI mode and the movement of the mouse no longer makes the camera move. I’m using this mode to allow the player to click on actors placed in the world.

Once an actor is clicked, they display a unique UI element to the screen that only takes up a portion of the screen and has buttons on it allowing the player to direct the actors behaviour (Example: Activate a skill move).


(My screen capture doesnt capture the mouse cursor for some reason but in reality, the mouse cursor is visibile in the above image)

When I click on the actor the first time, it brings up its unique abilities bar, from there I can either click on the button on the UI element or click on the world (select a different actor and so on), so far so good.


(Button on UI element is pressed and registered; String is printed to screen for debugging)

The issue is though, If I click on the world, I can no longer click back on the button in the UI element (it becomes inactive for some reason). I want to be able to click on the world without the UI elements buttons becoming inactive (Cannot not click on them).

Assistance would be greatly appreciated, more than willing to provide further detail upon request… Many thanks!

Can you show the logic where you switch the Input Mode between Game Only and Game And UI?

Whenever I change that, I usually also change a variable on the player controller.
Get Player Controller → Set Show Mouse cursor (true / false)

I’m too lazy to screenshot, so look at this thread: Show mouse cursor in BP?

Hi Sonictimm, thanks for the reply… here is the requested screenshot:

Just to be clear, the mouse cursor not showing is not my issue, the hidden cursor by default is intended (i only want the cursor to show when the player holds RMB and that is implemented and works as intended too, its just that the screenshots dont show my cursor for some reason)… the cursor shows perfectly, its just that if i click on the world, the buttons on the UI element becomes inactive (still on the screen but i can no longer click on it)

1 Like

Three things can be causing this:

  • we enter Game Only input mode (I’d double-triple check that first)
  • something else (another widget) consumes mouse input

Once an actor is clicked

What happens when this terminates / is cancelled?

I’m certain we do not enter game only mode when we click. I suspect it has something to do with the Game and UI input mode (Image shows the description of the node):

I suspect when the click is not handled by the UI, it gives “player input / player controller” a chance but it doesn’t ever switch back to allowing the UI to handle the click. Any ideas?

  • how do you detect clicks in the widget?
  • does the widget have enough hit-testable elements to start with?
  • have you tried setting widget focus with the Game and UI input node

image


Place a regular native button in the widget as a test (if you have none), they are infamous for stealing focus whenever hovered/clicked. Can you click a simple button? If you cannot, it’s time for the Widget Reflector debugging:

1 Like

I believe nothing, here is the logic:

Check if mouse cursor is on (dont want anything to happen if its off)

Then check if we have a ref to an actor, if we dont, we get the ref to the actor under the mouse (line trace) and get the actor to show its UI elements through a BP interface. If we already do have a ref to an actor, we tell it to move to the spot under the mouse curor.

Here is a screenshot of the widget class, the mouse cursor is hovering over the button (just noticed the screenshot is still not capturing the cursor, the button is the grey box with blue outline):

The strange thing is, the button works perfectly fine if i click on the button before clicking on the world… but once i click on the world, the button becomes inactive (just doesnt detect clicks)

And i have already tried the focus widget thing, no change.

If you cannot click the button:

  • we’re in the Game Only input mode
  • the widget (or its parent) is set to be not hit-testable
  • the widget is disabled
  • another widget consumes input

UI goes first in Game and UI mode; if unhandled, it tunnels to the PC. You cannot un-handle a button unless you actually use a precise-click. And even then, it’d be a hassle. I stopped using buttons for that reason alone - you just cannot shake them off.


Consider having a look at the widget reflector - it is a tool designed to handle this.

image

Start picking widgets in PIE, see what you get:


You could also Flush input on the nodes you have up there, in case something does get stuck, indeed.

1 Like

BTW thanks for your time. Heres what i got:

I have never used this so ur insight is appreciated.

You need to use it in PIE - Play in Editor - while you play. In the actual viewport of the game, when the issues manifest. In short, run the reflector, run the game, mouse over stuff that misbehaves, observe the list. Is the cursor hitting what it should be hitting - the button?

Got it, here is the results:

Hold on, hold on.

You actually get it to hover and display the tooltip?

You just cannot click it? Neat. Does it visually go down, like the hover states would suggest?

Correct, just cant be clicked. Sorry what do you mean by does it visually go down?

Buttons have states:

image

When you mash them, they enter said states, giving the user a visual clue as to whether they’re being used:

Does a default button do that?


So:

the button in the UI element (it becomes inactive for some reason)

Which clearly is not the case since we can hover it. What is the button supposed to do that it’s not doing. It does not execute script?

image

I want to be able to click on the world without the UI elements buttons becoming inactive (Cannot not click on them).

How does it manifest, exactly? What is not happening?

Heres a screen recording of the issue, hope this answers your question.

Is this a regular native button? I must say that I have not seen behaviour like this before. Hard to imagine what could be causing it. Not even sure how to repro this.

Yes

This one to be precise:

Then click logic:

Would you be interested in viewing the project for yourself? Ive got it on Github.

You ever figure this out? I ran into the same issue in unreal 5.0.