Buttons do not have a double click event, and I don’t want to watch the tutorial. Can you give me the break down of what you’re doing?
Double Click is an actual event in Slate, when detected, you receive a double click paired with a mouse up, instead of a mouse down, up, mouse down, up. If you’re some how combining the double click detection on a UUserWidget with a button on top of it, I don’t know that will go well, since the SButton in Slate listens for and treats the double click event like a mouse down.
Create a new project. (im using top down template for this example)
Create a widget and place a button on the canvas
override the function “OnMouseButtonDoubleClick”
drag off the OnMouseButtonDoubleClick and place a print string,
connect to return node and place a “handled” on the return value
save, compile, hit play
double left click, nothing
double right click or double middle mouse click and you WILL get the text.
It seems to be only on the left mouse button that there is an issue.
It’s working as intended. There’s no default double-click for buttons. At the moment you are overriding *OnMouseButtonDoubleClick *for the canvas the button is sitting on.
Make the canvas/parent container visible and double click anywhere but the button. You’ll see that the double-click works just fine.
When you left-click the button, it handles it as a single click; it will not allow you to click through and hit the canvas underneath.
Since there’s no default RMB button behaviour (not very intuitive to start with), the RMB on the button clicks through to the canvas unhandled by the button, allowing second click to connect with the underlying canvas as well.
You can use PreciseClick to click through a button - expand the Interaction tab of the button widget and change Click Method to PreciseClick. Still, this does not mean that the button is double-clicked, you’ll be hitting whatever is underneath it, which is fine if that’s what you’re after. The button is purely visual at this point.
I admit I did not watch the tutorial but you’re clearly tackling inventory here. Every slot will be a separate double-clickable widget with an image to show the item + tooltip. I wouldn’t use canvas & button for this - it will work, but it’s not very performant.
You can achieve an elegant result with:
[Overlay] (if you want to add text later, like a counter for example )
It will be more work, though, as buttons have that nice click-in - click-out behaviour, hover modes and so on. Stick with what works best for you.
Border has an in-built default double click event, btw.
You can stick with what you have for now, just make sure you enable PreciseClick for the button. Refactoring code for optimisation can (and in most cases should) be done at a later stage. If you’re not going to have 100+ inventory buttons on screen at a time, the performance impact might be negligible unless you target low spec/mobile. Good luck!
I think you might be experiencing what Nick was concerned about in his post.
So, essentially you need a widget that reacts to single RMB and a double LMB?
That should be pretty straightforward with a border. If you also need to handle a single LMB, you can, but it will most likely fire during double click event, too.
At the moment the intended use is as follows:
Lmb (down-held) drag item to another slot
Lmb (double clicked) use item
Rmb (Clicked) Spawns another widget which allows you to use, destroy etc the item
There is no left click (Up-Down) functionality.
Tbh im thinking of redoing the system entirely so i have this instead.
Lmb (clicked-held) drag item to another slot
Shift+Lmb (clicked (up-down)) use item
Rmb (Clicked (up-down) Spawns another widget which allows you to use, destroy etc the item
I think this will simplify the system considerably. it’s not over intuitive but it’ll work i think.
Firstly though, I’ll try doing it with a border. Even though what I’m working on is for PC i still want it as optimized as humanly (or computationally) as possible.
Hey, I think that one missing piece of information that is crucially missing here is that this worked OK in 4.16 but stopped working after update to 4.17. Everything else is correct what you said, this is not a button function but the Slate function that is being overridden. How it worked before was that BOTH events were triggered, the button On Clicked(or mouse button down or whatever else) and the parent event of OnMouseButtonDown, or in this case OnMouseButtonDoubleClick were triggered. Now the Button widget does consume the mouse events and the “parent” events are not triggered. If you set the button as disabled the parent events work ofcourse.
I actually tested this in 4.16.3 and the issue was still there.
Just to Update this once again, I got this working beautifully using everynone’s method.
Replace the button with a border.
Replace the button references in the graph with the border equivalent (set brush instead of set style)
Create 2 more function overrides for “on mouse enter” and “On mouse leave” and set the brush to the hovered and default
That’s pretty much it. Really appreciate the help everyone.
Yes that solution does work(more like a workaround btw).
Little thought experiment, it did not work for you, but the guy making the tutorial you are referencing does have it working on the older version of the engine => it worked before 4.17 and if what you are saying is true, which I suppose it is, he is on 4.16.2 or older. I am pretty sure that my OnMouseButtonDown did work with the button being present in the widget before my update to 4.17, unfortunately I am not sure which version of Engine I was using before as I do need to compile them from source and the update is not that easy so I do not do it very often:).
I belive issue here is that On Mouse Button Down blueprint function override does not fire at all for left mouse button in 4.17. It is working fine for right mouse button and was working with left mouse button too in 4.16.
From my experience, it has always worked and still works fine. Hook up a PrintString node to *onMouseButtonUp *and onMouseButtonDown and see for yourself.
The only issue we had here was a *ButtonWidget *consuming input.
To boil the whole thing down to a single sentence: With LMB, you want to drag a widget containing a clickable button widget, right?
If PreciseClick no longer works, you can always use onPreviewMouseButtonDown instead, it will work with both LMB and RMB.
But then you will just have to deal with button styles - the reason why I abandoned buttons when dragging (and never looked back!).
Okay, I understand I am just confused about the silent change between versions. Well, I found out another thing which can be connected to this change. IsHovered() returns false for widgets containing button when right mouse is clicked. I belive that right clicking does not change anything on fact, that mouse is still on widget, so it should be still true. We probably need to have IsDirectlyHovered() function to be exposed to blueprints, that one works correctly.