OnMouseButtonDown(function) → Set a bool variable to true
OnMouseButtonUp(function) → Set this bool var to false (and print)
If you Click and drag your cursor outside the window and then release mouse button… when you take the cursor back in the window, OnMouseButtonUp(function) wont execute…
I know this is intentional, but how can i deal with it?
The way buttons capture the mouse is somewhat special and comes with complications in some other cases.
I think the real question here is why would you need/like a behaviour like that.
In theory, you could save the mouse button state into a variable in onMouseLeave - bool ButtonWasDown(T). Leave the viewport, release the mouse. In the onMouseEnter, check what the state was and compare it to the current button state - IsMouseButtonDown. If it’s not down, it means it was released outside of the widget and you can simulate firing OnMouseButtonUp.
Untested but that could work.
Still, this is awkward and hacky. Another real question is: do you want to invest time and energy into something that may not be a gamebreaking feature?
For those ending up here looking for a solution, in the OnMouseButtonDown you can return an Unhandled event fed into a Capture Mouse event, which will let the widget listen to mouse events after it leaves the widget. Then in OnMouseButtonUp, do the same but return Release Mouse Capture instead (and possibly feeding in Handled instead of Unhandled to prevent the release triggering logic elsewhere, I haven’t tested that).