[BUG] UMG MouseButtonUp event only triggers on double click

I discovered the following bug while working with UMG in 4.18.1: You can reproduce it by following these steps:

  1. Create a new Blank Project without Starter Content
  2. Create Custom Game Mode and Pawn Blueprints.
  3. In World Settings, set your custom Game Mode as Default Game Mode
  4. In your Custom Game Mode, set your custom Pawn as Default Pawn
  5. Create an UMG Widget, add a Border element to its Canvas, Horizontal Fill, Vertical Fill, Size Y = 800, Brush Color Alpha = 0.2
  6. Bind on the OnMouseButtonUp-Event of the Border
  7. In the auto-generated, bound function, output some debug string message. Return Handled or Unhandled.
  8. Play in Editor and repeatedly click on the border, only double clicks will trigger the event.

The same happens in standalone, and when overwriting the widgets Mouse Up event

I bet you forgot to handle the mouse down first:

222261-capture.png

You can’t expect MouseUp to fire otherwise.

Thank you that works, but breaks the functionality of my logic

That’s unfortunate.

In case you can’t find a satisfactory workaround, consider sharing some details regarding what you’re trying to achieve. There might be alternatives available.

Good luck.

I want a selection box in a RTS-like manner, so you drag a box and select units in it. That should not be possible on the whole screen, only where is no other UI.
So I use a border to mark the area where this is possible. I need to unhandle mouse down, so normal single selection can take place also (which is in pawn logic, i know bad architecture). The problems are that

  1. What this thread is about
  2. That I need to click on that border first to get it focussed
  3. OnMouseMove doesn’t trigger while Mouse Button Down
  4. Pointer Event → GetScreenSpacePosition returns absolute coords (from OS desktop origin) which is bad for PIE or Windowed. Since drawing of the box occurs in a HUD-class and I pass the event information in my UMG Graph to this class (c++), I use VirtualDesktopToViewportPixel to convert it to viewport coords, but the conversion has no effect other than completely disabling any drawing (why ever).

I thought, since the mouse click is not realyy in a UI manner and is semantically linked to the in-game world, i catch the mouse events inside the pawn and pass it to the hud, completely omitting UMG. I will then have to find a possibility to only allow selection outside from UMG Widgets.

well there should be a default hanldling
this is really bad design