Disable National Forest Clicks

Is there a way to disable the popup that appears when a user clicks a national forest? If we can't disable the popup, is there a way to modify what shows in that popup? 


In certain environments we don't want the user to open a separate, uncontrolled browser. 

Hi,


For Windows, you can take a look at the following code:



uses
  FMX.TMSFNCWebBrowser.Win;


type
  TCoreWebView2NewWindowRequestedEventHandler = class(TInterfacedObject, ICoreWebView2NewWindowRequestedEventHandler)
  public
    function Invoke(sender: ICoreWebView2; args: ICoreWebView2NewWindowRequestedEventArgs): HRESULT; stdcall;
  end;




procedure TForm90.FormCreate(Sender: TObject);
var
  c: ICoreWebview2Controller;
  w: ICoreWebView2;
  t: EventRegistrationToken;
begin
  c := ICoreWebView2Controller(TMSFNCWebBrowser1.NativeBrowser);
  if c.get_CoreWebView2(w) = S_OK then
  begin
    w.add_NewWindowRequested(TCoreWebView2NewWindowRequestedEventHandler.Create, @t)
  end;




  TMSFNCWebBrowser1.Navigate('http://tmssoftware.com');
  TMSFNCWebBrowser1.ControlAlignment := caClient;
end;


{ TCoreWebView2NewWindowRequestedEventHandler }


function TCoreWebView2NewWindowRequestedEventHandler.Invoke(
  sender: ICoreWebView2;
  args: ICoreWebView2NewWindowRequestedEventArgs): HRESULT;
begin
  args.put_Handled(False);
  Result := S_OK;
end;


For cross-platform, we still need to take a look at how to implement this, as this differs from platform to platform.

That looks to be working. I'll keep testing and let you know if anything comes up. Thank you so much!


I had to change the OnCreate to:

  c := ICoreWebView2Controller(TMSFNCGoogleMaps1.NativeBrowser);
  if c.get_CoreWebView2(w) = S_OK then
  begin
    w.add_NewWindowRequested(TCoreWebView2NewWindowRequestedEventHandler.Create, @t)
  end;

And the Invoke to

function TCoreWebView2NewWindowRequestedEventHandler.Invoke(
  sender: ICoreWebView2;
  args: ICoreWebView2NewWindowRequestedEventArgs): HRESULT;
begin
  args.put_Handled(True);
  Result := S_OK;
end;

The code comes from AdvWebBrowser sample I wrote a couple of weeks ago, so could potentially contain some typos while converting the code to FNC. Thanks for the feedback.