From c99a44aab2cfac86290e11d7c35c8d918eb77b68 Mon Sep 17 00:00:00 2001 From: salvadordf Date: Mon, 11 Apr 2022 11:49:01 +0200 Subject: [PATCH] Show and hide browser tabs in FMXTabbedOSRBrowser --- .../FMXTabbedOSRBrowser/uBrowserFrame.pas | 13 +++++++++++++ .../FMXTabbedOSRBrowser/uBrowserTab.pas | 12 ++++++++++++ .../FMXTabbedOSRBrowser/uMainForm.pas | 18 ++++++++++++++++-- update_CEF4Delphi.json | 2 +- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserFrame.pas b/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserFrame.pas index e2a2cd59..07f0163e 100644 --- a/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserFrame.pas +++ b/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserFrame.pas @@ -143,6 +143,8 @@ type procedure NotifyMoveOrResizeStarted; procedure SendCaptureLostEvent; + procedure ShowBrowser; + procedure HideBrowser; {$IFDEF MSWINDOWS} procedure HandleSYSCHAR(const aMessage : TMsg); procedure HandleSYSKEYDOWN(const aMessage : TMsg); @@ -252,6 +254,17 @@ begin FMXChromium1.SendCaptureLostEvent; end; +procedure TBrowserFrame.ShowBrowser; +begin + FMXChromium1.WasHidden(False); + FMXChromium1.SetFocus(True); +end; + +procedure TBrowserFrame.HideBrowser; +begin + FMXChromium1.SetFocus(False); + FMXChromium1.WasHidden(True); +end; procedure TBrowserFrame.StopBtnClick(Sender: TObject); begin diff --git a/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserTab.pas b/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserTab.pas index f79090ec..e520da03 100644 --- a/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserTab.pas +++ b/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserTab.pas @@ -65,6 +65,8 @@ type procedure CloseBrowser; procedure ResizeBrowser; procedure FocusBrowser; + procedure ShowBrowser; + procedure HideBrowser; procedure SendCaptureLostEvent; {$IFDEF MSWINDOWS} procedure HandleSYSCHAR(const aMessage : TMsg); @@ -151,6 +153,16 @@ begin if (FBrowserFrame <> nil) then FBrowserFrame.FocusBrowser; end; +procedure TBrowserTab.ShowBrowser; +begin + if (FBrowserFrame <> nil) then FBrowserFrame.ShowBrowser; +end; + +procedure TBrowserTab.HideBrowser; +begin + if (FBrowserFrame <> nil) then FBrowserFrame.HideBrowser; +end; + procedure TBrowserTab.BrowserFrame_OnBrowserDestroyed(Sender: TObject); begin // This event is executed in a CEF thread so we have to send a message to diff --git a/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uMainForm.pas b/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uMainForm.pas index bc57c986..258e5538 100644 --- a/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uMainForm.pas +++ b/demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uMainForm.pas @@ -369,9 +369,23 @@ begin end; procedure TMainForm.BrowserTabCtrlChange(Sender: TObject); +var + i : integer; + TempTab : TBrowserTab; begin - if (BrowserTabCtrl.ActiveTab <> nil) then - TBrowserTab(BrowserTabCtrl.ActiveTab).FocusBrowser; + i := pred(BrowserTabCtrl.TabCount); + + while (i >= 0) do + begin + TempTab := TBrowserTab(BrowserTabCtrl.Tabs[i]); + + if (BrowserTabCtrl.TabIndex = i) then + TempTab.ShowBrowser + else + TempTab.HideBrowser; + + dec(i); + end; end; function TMainForm.CloseAllTabs : boolean; diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index e57941d9..8f32c1b8 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,7 +2,7 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 381, + "InternalVersion" : 382, "Name" : "cef4delphi_lazarus.lpk", "Version" : "100.0.14.0" }