How do you listen to right click events on an element? #800
-
QuestionThe vue way of reading rmb events seems to be using Would also like to be able to cancel the browser default RMB menu. While Im well here I might as well ask for double click & if its possible to listen to keyboard presses on a per element basis (so, I only want to receive events if the element the event belongs to is hovered while a key is pressed). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I'm not sure if "right" is a valid event modifier. But apart from that it looks like the But you can subscribe to a ui.label('Right click me').on('contextmenu.prevent', lambda: ui.notify('Right!')) And handling double clicks can be done using the ui.label('Double click me').on('dblclick', lambda: ui.notify('Double!')) |
Beta Was this translation helpful? Give feedback.
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 normalclick
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:And handling double clicks can be done using the
dblclick
event: