Page 1 of 1

Disable right click ?

Posted: Wed Oct 23, 2019 4:53 pm
by thefunkyjoint
Hello,

Is there a way to disable the menu that opens when the user right-click on a page ?

Thanks

Re: Disable right click ?

Posted: Wed Oct 23, 2019 7:32 pm
by salvadordf
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

Re: Disable right click ?

Posted: Thu Oct 24, 2019 12:09 am
by thefunkyjoint
Thank you !

Even better : can i replace its menu for my own TPopupMenu ? Would be awesome !

Re: Disable right click ?

Posted: Thu Oct 24, 2019 7:32 am
by salvadordf
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.

Re: Disable right click ?

Posted: Thu Oct 24, 2019 7:06 pm
by thefunkyjoint
That's awesome, thank you very much Salvador ! :D