Rclick event in a listbox

The MSG object event property for a listbox includes rclick and selchange. Right clicking an item triggers a selchange event and a rclick event in that order. I would like an option to give priority to rclick such that the event order is reversed or alternatively such that the selchange event is supressed and is effectively replaced by rclick.

My use case is a list where I would like to trigger action A if an item is left clicked and action B if an item is right clicked.

The item is selected as part of the right click. That’s how the Windows control works and not something we are doing.

To handle the right click without reacting to the selection change, you could set a short timer in response to the selchange event and kill the timer in the right click event, then handle the left click if the timer makes it through. (KillTimer and SetTimer ate methods in the Dialog object.)

Remember to kill the timer the first time the timer fires as well, else it will keep firing.

1 Like

Thanks. I wasn't aware of SetTimer and KillTimer. A neat solution.

1 Like