UMG button OnClicked conflicts with OnPreviewMouseDown

I’m trying to do a Drag & Drop function on a button using “onpreviewmousedown”, but it’s keeping the widget from triggering the “oncliked” event. I have to do a double click in order for it to trigger “onclicked”.

Is there a way to fix this? I wanted to keep the engine’s functionality to handle visual styles for button pressed etc.

Any reason why we’re using this one :point_up_2:? Are you dragging a native button or plucking something out of a scrollbox? Attempting to drag a native button in UMG (or making it do unbuttonlike things is like shooting oneself in the foot).


Not sure if applicable: if you need buttons to do anything more than the mundane fire & forget, it pays off to make a custom button and juggle your own styles. As mentioned in the other post, a user widget made out of a prettified border with material, script your own styles / sound handling and an optional exposed Named Slot. It’s some upfront work, sure, but you do get all the flexibility and none of the input consumption shenanigans native buttons manifest.

1 Like

Yeah, I’m using native buttons, as I’m still prototyping the interface.

How would one handle on hovered/pressed/released etc styles with a custom button?

Note that you would not be using a native button at all, you’d use a border and change the way it looks like:

  • OnMouseEnter
  • OnMouseLeave
  • OnMouseDown
  • OnMouseUp
  • OnMouseMove
  • and more, ofc - would you like to double right click an UI element while holding shift+ctrl? Because you cannot do it with a native button.

Now, since this new custom button is a user widget, dragging, bubbling, tunnelling input is less of a nuisance. Technically, you could have a (non-interactive non-hittable) button in the layout as well and change its styles if you must use them for convenience. The idea here is not to use a native button for anything more than simple clicking, since even right clicking a native button is an obstacle.

onpreviewmousedown

This was introduced solely for handling some uncanny scenarios.


And there’s also the entire concept of:

1 Like

Thank you, this is valuable information. Seems clear to be the best approach to proper interface interactions.

Now, for prototyping purposes only, would you use OnMouseDown instead of OnPreviewMouseDown? To be honest I don’t know why one would use the Preview variation of it, I’m using it only because I saw it on two different videos regarding drag and drop operations

There’s no need for the preview. There should never be, it’s there as a last resort if there’s no other way to handle things. For dragging, it’s just onMouseDown. Just do not drag native buttons - they will refuse to work. Since you’re prototyping, make a user widget with a Size Box + Border and you’re good to go.

1 Like