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.

Context menu with function

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

Context menu with function

Post by thefunkyjoint »

I know how to personalize the context menu as the example below. But how can i add an Item that will call my own specific procedure ?

Thanks

procedure TForm1.OnBeforeContextMenu(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams;
const model: ICefMenuModel);
begin
model.clear;
model.AddItem(CEFBROWSER_CONTEXTMENU_BACK, 'Back');
model.AddItem(CEFBROWSER_CONTEXTMENU_FORWARD, 'Next');
model.AddItem(CEFBROWSER_CONTEXTMENU_RELOAD, 'Reload');
model.AddSeparator;
model.AddItem(CEFBROWSER_CONTEXTMENU_COPY_URL, 'Copy link');
end;
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Context menu with function

Post by salvadordf »

Hi,

Use the TChromiumCore.OnContextMenuCommand event and call your custom function when commandId has the same ID value that you added in TChromiumCore.OnBeforeContextMenu.

The MiniBrowser demo shows how to use those events here :
https://github.com/salvadordf/CEF4Delphi/blob/805be3e7800ed74500c32b48c7ffab4495e53427/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L552
thefunkyjoint
Posts: 460
Joined: Thu Aug 10, 2017 12:40 pm

Re: Context menu with function

Post by thefunkyjoint »

Thank you, it worked ! :D
Post Reply