How to create a drag and drop button using CommonUI? (C++)

I’m using CommonUI with C++, but I’m having trouble figuring out how to get a UCommonButtonBase to work with drag and drop operations. With a normal UButton, I’d just override NativeOnMouseButtonDown and use DetectDragIfPressed (or similar) to return a reply.

UCommonButtonBase of CommonUI, however, doesn’t use NativeOnMouseButtonDown as far as I can tell. I’ve found NativeOnPressed, but it doesn’t return an FReply or take in a mouse event. I also can’t find anybody online talking about this. Help would be greatly appreciated.

1 Like

Hi

I had some challenges with this as well, i solved it with a bit of creativity, so you might not like the proposed solution :slight_smile:
This solution does not involve using the standard drag and drop functions, just a way to get button events on drag and drop.

Basically you set the buttons to use ‘precise click’ method to support drag dropping, then set press method to ‘button press’. Use ‘mouse enter event’ and check if the mouse button is down, on true set click method to ‘mouse up’ so it can receive the drop. On mouse leave event and button click event you reset back to precise click method.

Button press → Drag started
On Button Click(Has up click method) → Drag drop
On Button Click(Has precise click method) → Use