Detecting Doubleclick over Button

Hi there,

is there a clean way to detect a doubleclick over buttons?
WasInputKeyJustPressed(EKeys::XXXX) seems as it only have a single mouse button pressed.

I found that there is a IE_DoubleClick, but it seems more usable to me for gameplay than for picking/ equiping items from the inventory.

Thanks in advance

I’m not sure in what context you refer to “button” here. Assuming Slate or UMG, SButton/UButton is a very specialized class that only hooks a shortcut to MouseDown/MouseUp based on the click behaviour you’ve picked. SBorder/UBorder gives you full control over the pointer events, namely provides a DoubleClick listener:



// Slate
SLATE_EVENT( FPointerEventHandler, OnMouseDoubleClick )

// UMG
UPROPERTY(EditDefaultsOnly, Category=Events)
FOnPointerEvent OnMouseDoubleClickEvent;


Using a Border would give you access to this event, but you’ll have to manually handle the extra fluff that comes with buttons such as sounds, disabled state, etc.

Thanks ,

I’m using canvas(or how the older system is called), no UMG or Slate. I tried UMG, but moved back to the older system since I prefer C++ far over Blueprintnodes.

Do you think I could mix the UMG method with canvas?

Unfortunately, Canvas is as basic as it gets (which is largely the intent) and barely has any input handling. You would have to manually detect double click by setting up a timer and seeing if it is close enough to a previous click.

I’m a bit surprised you’d undertake something as big as an inventory system using nothing but Canvas. I can definitely relate to not wanting to deal with blueprint for fairly complex UIs, which is why I implemented our UI using mostly Slate and C++, with only the layout and presentation being done in UMG. All I do in UMG blueprint is assign the widgets created to properties in my C++ base class to use with business logic.

It’s not a simple system to learn by any means, but I’d encourage at least looking into Slate if you plan on making your UI remotely complex. Once I got a good handle on it, I ended up skipping UMG altogether in many cases. Just be prepared to dig around the editor and engine code because that’s where the majority of Slate “samples” exist.

And yeah, you can mix and match Slate/UMG widgets alongside Canvas calls. But for the specific case of a button, it’d probably be more complicated to try and use both systems at the same time.