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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

add "open in new tab" item

Post Reply
nimq
Posts: 10
Joined: Thu May 09, 2019 10:11 pm

add "open in new tab" item

Post by nimq »

I want add "open in new tab" item to the context menu. How can I do this?

I can get a link href from the DOM and open the link in new window, but in this case an OnClick event handler does not execute.

Also I can not emulate click and use BeforePopup event in my case BeforePopup event does't execute becouse my site is SPA and just use history.pushState and history.replaceState with ajax query
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: add "open in new tab" item

Post by salvadordf »

Hi,

The "Open in new tab" menu option is added manually in your app, not by CEF.

In order to trigger the TChromium.OnBeforePopup event you need to modify the HTML or JS code to open that URL in a new tab.

You need to do something very similar to the PopupBrowser2 demo but using tabs instead of child forms.

As explained in the PopupBrowser2 code comments, you need to create a hidden tab with a browser. Then call TChromium.CreateClientHandler when the TChromium.OnBeforePopup event is triggered.

The OnClick event is executed only if you call TChromium.CreateClientHandler inside TChromium.OnBeforePopup.
Post Reply