I’m working on an inventory using the vanilla drag and drop features. I don’t want to re-invent the wheel unless no other options are available.
My problem is there seems to be no way of detecting a simple click on an element unless you make it a button, however you can’t drag those.
UE4 already handles a lot of interactions out of the box, but no OnClick event is present anywhere that I’ve seen. Closest thing would the OnDoubleClick event.
I need the widget to be both draggable and clickable, so you can drag it around, but also trigger click events from it.
I’ve been googling for days with no luck.
yeah, i knew that. is what I’m using for the drag detection already (which i mentioned in my initial post…)
Anyway. I got it to doing what I wanted by using the on button up event. I just didn’t know you could leave the event “unhandled” which is what i was missing annoyingly.
My bad, refreshed after sending this to find you’d already gotten to this point lol
In each user widget you want to register clicks on, you can override OnMouseButtonDown/Up.
Note that it requires an event reply as a return value. This is just a way of telling the input handler whether the input has been “handled” or not by this widget. If unhandled, the input can “bubble up”, and be processed by over mouse events. If handled, the input is consumed.
Hope this helps, if you also need help specifically with the drag and drop functionality, feel free to reply with more questions
I need the widget to be both draggable
and clickable, so you can drag it
around, but also trigger click events
Most widgets have a bunch of overridable events:
You then add a dispatcher to ferry any data you need:
So you can then bind the dispatcher:
Buttons already dispatch basic stuff, for example. Borders don’t - but thanks to that they are super flexible.
Example of this in action:
I try to move a widget when I press the mouse button down. It do move hut it can’t follow the mouse cursor and when I release the mouse button the widget will still move. the code is set up to stop moving the widget when the mouse button is released....
Reading time: 1 mins 🕑
Likes: 3 ❤
Yeah, I went overboard with explanations, my bad.
Handled / Unhandled tunnelling thingy is key here, true.
and where can I find that mouse button up, it’s not showing anywhere