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 ?

Post Reply
thefunkyjoint
Posts: 460
Joined: Thu Aug 10, 2017 12:40 pm

Disable right click ?

Post by thefunkyjoint »

Hello,

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

Thanks
User avatar
salvadordf
Posts: 4067
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Disable right click ?

Post 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
thefunkyjoint
Posts: 460
Joined: Thu Aug 10, 2017 12:40 pm

Re: Disable right click ?

Post by thefunkyjoint »

Thank you !

Even better : can i replace its menu for my own TPopupMenu ? Would be awesome !
User avatar
salvadordf
Posts: 4067
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Disable right click ?

Post 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.
thefunkyjoint
Posts: 460
Joined: Thu Aug 10, 2017 12:40 pm

Re: Disable right click ?

Post by thefunkyjoint »

That's awesome, thank you very much Salvador ! :D
Post Reply