Right click fires the unhovered event in ui

Good Day,

I could not find any questions regarding this so decided to ask,

when right clicking inside a button with hovered and unhovered events, the right click will fire the unhovered event.
Is this intended or a bug.

Recreate.

add a button to the viewport with both hovered and unhovered events enabled.
Hovered set a bool (mouse_in_UI) in player controller to true.
Unhovered set the bool to false.
print the result.

now whilst playing hover the mouse over the button to see it succeed, when you press the right mouse button it will trigger the unhovered event for as long as you hold the mouse down.

1 Like

Actually as far as I know if you are on Input Game and UI any sort of click disables the Hovered state checks - it will return false, always. As if you clicked “under” the widgets, probably because the “game” part takes focus while holding the mouse button. Interestingly enough keyboard input doesn’t seem to cause such problems.

If we could have access to all the inputs even with “input mode ui only” it would be so much easier to deal with this… without roundabout hackery that is.

I’m doing a minigame where you can rotate tiles left and right. LMB to left, RMB to right.
The board is set up runtime so I need to check which tile is Hovered. But if I click the tile is not hovered, ever :slight_smile: If you click straight after if works. So essentially it works if you doubleclick LMB or RMB.
Since I can’t even get the info where the tile is on the screen (so far didn’t find a simple way) this is annoying me quite a bit.

1 Like

It’s been awhile since this question but I found a solution that should help most of the people that have this problem.

Thanks to your sugestion that its related with Input Mode I figured out that overriding function “OnMouseButtonDown” and make it return Handled, its no longer going to focus game instead of UI. In cpp this funtions is named “NativeOnMouseButtonDown”. In some cases function named “OnMouseButtonDoubleClick” should be returning handled too.

If you are holding you widgets inside of other widgets you can override it only on parent widget that will handle all clicks done on its childs.

There is still a case in which you will press mouse button without widget under it, that will make Input Mode to focus game part and hovers will not be detected until all mouse buttons will be released. For this you can put invisible widget on whole UI that will handle clicks but it has a down side that mouse events will no longer be detected by game, only by UI.

Thanks a lot for sharing

Aaaand this comment is going into my repository. It completely eluded me that you can just click that override button and actually massacre those events. Yea, I’m getting senile it seems…