How to listen to the right click event on the canvas? #4844
kamalesh-d
started this conversation in
General
Replies: 1 comment 9 replies
-
You can get the iframe document from the canvas and catch your events editor.Canvas.getDocument().addEventListener('contextmenu', (ev) => {
ev.preventDefault();
console.log('contextmenu inside canvas iframe');
}) |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
First of all thank you very much for making such great project in open source.
Can someone please help me, what is the way to listen to the right-click event on grapesjs canvas? I wanted to listen to this event and open a context-menu for designing the element at which the click was performed.
I learnt to get the current selected component from the canvas based on the following code:
editor.on('component:selected', (selectedcomponent) => {
# Selected component can be processed as I want.
});
However, I am not able to listen to the right-click event. I am working with Vuejs, what I tried is:
HTML content
Vue method
rightClickHandle(){
alert('right clicked');
}
Normally, it shall be able to detect the right click in this way. But since the canvas is attached through 'gjs' id, I need to know if there is a way grapesjs (API) allows us to listen for the right-click event.
Please let me know if any additional information is required.
Thanks in advance,
Kamalesh D.
Beta Was this translation helpful? Give feedback.
All reactions