|
Rank: Member Groups: Member
Joined: 9/4/2017 Posts: 10
|
Hello,
I've been trying to save images using the context menu. I can save an image, by obtaining the base64 through javascript. When testing I had this function on the mouseclick event, where I can freely call evalscript.
the beforecontextmenu call, required for modifying the context menu of my view, does not support evalscript.
This leaves me with no obvious method to test the current location of my click to there being an image there I can actually save. I want to prevent the item being visible, of no image can be saved.
Is there a way to check the current location of the context menu, while in the beforecontextmenu event, so that I can make the context menu actually context sensitive in this situation?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,225
|
Hi,
There is no way for you to run JavaScript code from within BeforeContextMenu event because it's a blocking event. However you can check e.MenuInfo.MediaType inside your event handler to see whether the node below is an image.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 9/4/2017 Posts: 10
|
Hi,
Thanks for your reply.
This works in the event of an image, but not when there is a div with a background image. That has a mediatype of None.
Kind regards, Paul
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,225
|
Then your only option would be NOT using the built-in context menu and display the context menu yourself. You would need to:
1. Disable the built-in context menu by calling e.Menu.Items.Clear() in your BeforeContextMenu event handler; 2. Handle the WebView's MouseDown event. Inside the event you can check whether the right button has been clicked and then display your own context menu;
Please let us know if this works for you.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 9/4/2017 Posts: 10
|
ahh thanks,
I was wondering if there was an override. Good to know that can be achieved by removing all the items. Consider my question answered.
Kind regards, Paul
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,225
|
You are welcome. Please feel free to let us know if you run into any other issues.
|
|