Hello,
Is there a way to disable the menu that opens when the user right-click on a page ?
Thanks
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Disable right click ?
- salvadordf
- Posts: 4572
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Disable right click ?
Hi,
Call model.clear inside the TChromium.OnBeforeContextMenu event to disable the context menu.
Read this for more information :
https://magpcss.org/ceforum/apidocs3/pr ... ndler.html
https://magpcss.org/ceforum/apidocs3/pr ... Model.html
Call model.clear inside the TChromium.OnBeforeContextMenu event to disable the context menu.
Read this for more information :
https://magpcss.org/ceforum/apidocs3/pr ... ndler.html
https://magpcss.org/ceforum/apidocs3/pr ... Model.html
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Disable right click ?
Thank you !
Even better : can i replace its menu for my own TPopupMenu ? Would be awesome !
Even better : can i replace its menu for my own TPopupMenu ? Would be awesome !
- salvadordf
- Posts: 4572
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Disable right click ?
You can add and remove menu items, and execute your own code for each of them.
Use TChromium.OnBeforeContextMenu and call "model.AddItem" to add new items as you can see here :
https://github.com/salvadordf/CEF4Delph ... r.pas#L370
Use TChromium.OnContextMenuCommand to execute your own code for the new menu entries :
https://github.com/salvadordf/CEF4Delph ... r.pas#L504
Both events are executed in a CEF thread. It's recommended that you don't create, destroy or modify any VCL control inside them. Send windows messages to the form to execute the code for each menu entry.
Use TChromium.OnBeforeContextMenu and call "model.AddItem" to add new items as you can see here :
https://github.com/salvadordf/CEF4Delph ... r.pas#L370
Use TChromium.OnContextMenuCommand to execute your own code for the new menu entries :
https://github.com/salvadordf/CEF4Delph ... r.pas#L504
Both events are executed in a CEF thread. It's recommended that you don't create, destroy or modify any VCL control inside them. Send windows messages to the form to execute the code for each menu entry.
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Disable right click ?
That's awesome, thank you very much Salvador ! 
