Page 1 of 1

add "open in new tab" item

Posted: Tue Sep 24, 2019 10:28 am
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

Re: add "open in new tab" item

Posted: Tue Sep 24, 2019 12:22 pm
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.