Skip to content

How do you listen to right click events on an element? #800

Closed Answered by falkoschindler
ItsCubeTime asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure if "right" is a valid event modifier. But apart from that it looks like the contextmenu event gets in the way, such that even a normal click event is not emitted when using the right mouse button.

But you can subscribe to a contextmenu event and prevent the default behavior like this:

ui.label('Right click me').on('contextmenu.prevent', lambda: ui.notify('Right!'))

And handling double clicks can be done using the dblclick event:

ui.label('Double click me').on('dblclick', lambda: ui.notify('Double!'))

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ItsCubeTime
Comment options

@falkoschindler
Comment options

@kfalcami
Comment options

Answer selected by ItsCubeTime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants