In-game Context Menu with Top Down input

Hello, I have created an in-game context menu activated by clicking and holding the right mouse button. The context menu disappears when RMB is released. The base of the context menu is from a video I watched on Youtube.

This project is based on the Top-Down example, so the primary gameplay input is the left mouse button (click on a spot to go there)

However, I am having some problems with input.

The Input Mode has to be set to “Game & UI” after the context menu widget is revealed (in the Widget BP event graph), in order to be able to hover and click the buttons of the widget.

However, if I do this, clicking on a button in the context menu widget also triggers the “Go here” LMB event in the player controller.

I’ve tried a bunch of things, like checking the status of RMB before going through with the LMB “go-here” event, switching the input mode at various points in the process, etc.

It seems like my main problem is how LMB is considered part of the Game input mode, when I need it to be both Game and UI, just at different times.

I should add, the requirement of hiding the menu when RMB is released added this complication.

The desired behavior is:
Right-click on an actor and keep RMB held down.
Context Menu comes up showing some options. With RMB held, one button can be clicked with LMB, which does something and closes the menu.
If RMB is released at any time the menu closes.
Is there some way to accomplish this?

Here’s an album showing the blueprints.

Have you tried using Set Input Mode UI Only in OpenContextMenu function?

PS: I believe it would better if I could use an option just by releasing RMB over it. No need for LMB.

Hi, thanks for your reply. Yeah I’ve tried that. It almost seems as if the inputs are queued.

I also agree that it would be better if the options were selected by releasing RMB. I have the X and Y mouse position which could be used to determine the button currently being hovered, but hopefully there is some kind of hover event for the individual buttons I could use instead.

Edit: There is such an event and I am rewriting the menu to use RMB released input on the buttons instead of LMB. I will make another update when that is done

Better solution for LMB is Listen for Input Action:

https://www.youtube.com/watch?v=4FwaHM6YSF8