OnClicked Event only fires when double clicked.

Hey, i have a issue with the OnClicked Event when i click on a button which is a child of a child … I explain :

I have a inventory system with a main widget which contain my inventory widget and this inventory widget contain the slots widgets (slots are generated automatically, they are in the Grid Panel) :

Main HUD :

227688-capture.jpg

Inventory Widget :

227689-capture2.jpg

Slot Widget :

227690-capture3.jpg

The problem is i have to doubleclick on my “Btn_Slot” to launch a “OnClicked” event.

Edit :

  • If i create a simple button directly on my main widget, i have no issue when i click on it.
  • If i put my “W_Inventory_Slot” directly on my main widget, i have to double click on the button to launch the “Onclicked” event".

The “ItemIcon” and “TextAmount” are “Self Hit Test Invisible”.

I need help and tell me if you want more info about this !

Sounds a bit as if the wInventory was not getting the focus it needs to pass onto the button (when the mouse enters it) - could you try setting the wInventory to SelfHitTestInvisble or Visible? See if that helps.

The “ItemIcon” and “TextAmount” are
“Self Hit Test Invisible”.

You can set them to HitTestInvisible here - since you’ll never want to click them anyway, saves performance.

Hey, thanks for your answer, I tried to setting the wInventory to SelfHitTestInvisible (it was visible) but i have the same issue… There is a problem in the W_Inventory_Slot i think, because when i put it directly in my main HUD, i have to double click on it to fire the “OnClicked”… Maybe i missed something, i’m new on unreal …

Could you confirm something for me, please?

When you run the project, your initial click on the button (that’s inside a custom widget) does not register, right. But once you’ve clicked it once, addition clicks do register correctly? Even if you start clicking other UI elements or leave the widget.

If you need the initial click to instantly register with widgets, change the Default Viewport Mouse Capture Mode to Capture During Mouse Down. It’s in the Project Settings > Engine > Input. Bottom right corner of the image below:

After clicking one time, additional clicks don’t register correctly… Only double click fire “OnClicked”.
I already tried to change the Default Viewport Mouse Capture Mode, but same issue … =(

If i put a simple button in my W_Main, “OnClicked” of this button fire with only 1 click, if it can help

So it’s only the nested widget that acts up.

I asked after giving it a quick test in an empty project and seeing it works fine with custom widgets nested with buttons.

An additional question then. Do you, at some point, try to detect onMouseDown or Up?

Yes ! I have OnPreviewMouseButtonDown, i’ll try to add left click down here

Thanks ! I added left mouse button down here and now it works fine. Thanks you for taking the time to help me ! I didn’t know that this function override the OnClicked Event.
Yes i want to implement DragAndDrop later, and the function “OnMouseButtonDown” dont work for me with left click…

edited: Your OnPreviewMouseButtonDown - what does it return?

Ah, makes sense now! Epic removed the easily accessed ability to drag buttons around and now OnPreviewMouseButtonDown is needed fro that but it does come at a cost…

One thing to consider before you go too deep into this UI. Try not to get used to dragging buttons, see if you can use borders instead. Will save you lots of headaches.

Good luck!

Ok, thanks for the tips =) Thank you again for taking the time to help me !

Confirm that the widget is focused. The first click may be focusing it, then the second is the normal click event