OnMouseDown and button in UMG

I’m trying to create a drag and drop spell book / action bar.
I’ll override the “OnMouseDown” event to detect a drag if pressed left mouse button.
However, enablind the button consumes the “on mouse down” event and the drag and drop won’t happen and i wan’t to be able to click on the button to call whatever it’ll do with it.
I have no idea how, because i think i didn’t do anything different(and after analyzing both BP, it really seems i didn’t) but on my inventory slots it seems to work fine both button and drag and drop.
How can i use both? Or a workaround?


Experiment with button’s precise click and you’ll get it to work:


This is working but when i click , if a drag and drop happen and i move away from the button, the button style will be the “Pressed” until i mouse over it. How do i fix that?

I am not too convinced whether using buttons for drag & drop is a good idea to start with; sure thing it’s doable but you might keep running into nagging issues like that.

So let me see if I understood you right, you want to:

  • click and hold on a button, detect OnMouseDown, button *Style *is Pressed
  • create a drag & drop operation OnDragDetected
  • drag the visual away
  • when you slide off the button, revert it back to its NormalStyle

Is this more or less it or did I misunderstand something?

Thats pretty much it. Also , why do you think using a button is not good for drag and drop?
And i’m using a button because , since i’m with a spell , i wanted the click to cast the spell aswell, not only using the actionbar shortcut.
Also, the button has pretty much everything ready for those stuff already. Hover , Pressed and normal style, support for sound, etc…

The buttons have their own built-in functionality and switch states automatically: Normal-Hovered-Pressed - and you have no control over it; or to be more precise - this functionality is not exposed to blueprints.
Using precise click and initiating a drag operation robs the button of the opportunity to respond and switch states accordingly - you noticed the button getting stuck.

I know buttons and their styles are neat the included features seem like the way to go but you can replicate all that with a border - it even has its own *OnMouseButtonDown *.

My advice is to avoid drag&drop with buttons if you do not want to deal with the side effects you observed.