[4.13.0] Event On Mouse Leave doesn't fire when holding the mouse button down

As the title says, the blueprint event On Mouse Leave doesn’t fire when you press the widget and hold the mouse button down when moving the cursor out of the widget. The On Mouse Leave event will never be fired then.

If your code relies on the Mouse Enter/Leave events to detect whether the mouse is above it or not, which mine does, it will create a very buggy experience.

You also have the Is Hovered function, but it suffers from the same bug as the events do.

This bug wasn’t happening in 4.11, it is a bug introduced in 4.12 or 4.13.

Hey -

Based on the answer provided here (BUG: UMG OnMouseEnter does not trigger when mouse is locked to game window - Programming & Scripting - Epic Developer Community Forums ) I found that adding the “Set Input Mode UI Only” node to dictate how the widget reads the input will allow the Mouse Enter / Leave events to fire correctly.

Cheers

Please re- my post. The input mode is already being set to UI, and mouse enters are working correctly in my case. I am experiencing a bug where mouse leave isn’t working correctly if you are holding the mouse button down during the mouse leave. Again, this bug didn’t exist in 4.11, it appeared in either 4.12 or 4.13.

With the setup shown below my On Mouse Leave and OnUnhovered events would trigger even if the mouse button was held.

Can you post a screenshot of the setup you’re using and also let me know if this setup works for what you’re intending to do?

I went through the trouble to make a new project that contains this bug.

In the project, mouse over and leave the white square and it will show Enter and Leave.

Mouse over the white square and hold the mouse button down when leaving it and it will never show Leave.

This bug didn’t happen in 4.11 by the way.

This bug is of importance to me since I’ve created every widget I use myself in blueprint, like buttons and checkboxes for example. I did this to have the maximum amount of control over them and to be able to do things that I wouldn’t be able to do with normal buttons and checkboxes etc. With this bug, my entire UI bugs out when someone drags the mouse out of a widget, which makes the game way to buggy to be released. Luckily I’m still a couple months away from finishing the game, but nonetheless, I would like to have this fixed as soon as possible.

Anyway, maybe I forgot to do something critical which wasn’t necessary in 4.11 but is in 4.13, but I have no idea what that would be.

I’ve also tried the Left Mouse Button solution you’ve posted in your screenshot, but the thing is, is that the mouse enter/leave events don’t work when the input mode is UI only (edit: this turned out to not be true, apparently just keeping the mouse button pressed causes the events to not be fired). I’ve kept the code in the project so you can see it for yourself. Press [B] on the keyboard to enable/disable your Left Mouse Button solution.

I have entered a report for the On Mouse Enter, On Mouse Leave, OnHovered, and OnUnhovered events behavior with the mouse button held that can be viewed and voted on here: Unreal Engine Issues and Bug Tracker (UE-35687) .

Given your sample project, you should be able to add a Get Player Controller node where you are setting the Input Mode UI Only temporarily.

Thanks for adding the bug report.

Apparently, the problem only happens when the input mode is [Game and UI]. When the input mode is [UI Only], it doesn’t bug. This wasn’t put in the bug report, so I’ll post it here.

Also, I’ve found a working hotfix: just place every custom widget in a transparent padding-less button, and then use the button hover events (which do work correctly) for your hover code.