mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-02-12 10:26:05 +02:00
Fixed some focus issues in FMX demos for Windows in normal mode
This commit is contained in:
parent
acd6deb308
commit
41490cebdb
@ -98,10 +98,19 @@ object BrowserFrame: TBrowserFrame
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 4
|
||||
OnResize = WindowParentLayResize
|
||||
object FocusWorkaroundBtn: TButton
|
||||
Position.X = 304.000000000000000000
|
||||
Position.Y = 120.000000000000000000
|
||||
Size.Width = 1.000000000000000000
|
||||
Size.Height = 1.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object FMXChromium1: TFMXChromium
|
||||
OnLoadError = FMXChromium1LoadError
|
||||
OnLoadingStateChange = FMXChromium1LoadingStateChange
|
||||
OnGotFocus = FMXChromium1GotFocus
|
||||
OnAddressChange = FMXChromium1AddressChange
|
||||
OnTitleChange = FMXChromium1TitleChange
|
||||
OnBeforePopup = FMXChromium1BeforePopup
|
||||
|
@ -63,6 +63,7 @@ type
|
||||
StopBtn: TSpeedButton;
|
||||
URLEdt: TEdit;
|
||||
WindowParentLay: TLayout;
|
||||
FocusWorkaroundBtn: TButton;
|
||||
|
||||
procedure BackBtnClick(Sender: TObject);
|
||||
procedure ForwardBtnClick(Sender: TObject);
|
||||
@ -80,6 +81,7 @@ type
|
||||
procedure FMXChromium1LoadError(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring);
|
||||
procedure FMXChromium1LoadingStateChange(Sender: TObject; const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean);
|
||||
procedure FMXChromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring);
|
||||
procedure FMXChromium1GotFocus(Sender: TObject; const browser: ICefBrowser);
|
||||
|
||||
protected
|
||||
FClosing : boolean; // Indicates that this frame is destroying the browser
|
||||
@ -140,7 +142,7 @@ end;
|
||||
|
||||
function TBrowserFrame.GetFMXWindowParentRect : System.Types.TRect;
|
||||
var
|
||||
TempRect : TRectF;
|
||||
TempRect : TRectF;
|
||||
TempScale : single;
|
||||
begin
|
||||
TempScale := FMXChromium1.ScreenScale;
|
||||
@ -168,13 +170,14 @@ begin
|
||||
begin
|
||||
FMXWindowParent.WindowState := TWindowState.wsNormal;
|
||||
ResizeBrowser;
|
||||
FMXWindowParent.Show;
|
||||
FMXWindowParent.Visible := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.HideBrowser;
|
||||
begin
|
||||
if (FMXWindowParent <> nil) then FMXWindowParent.Hide;
|
||||
if (FMXWindowParent <> nil) then
|
||||
FMXWindowParent.Visible := False;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.DestroyWindowParent;
|
||||
@ -203,7 +206,8 @@ begin
|
||||
begin
|
||||
FMXWindowParent := TFMXWindowParent.CreateNew(nil);
|
||||
FMXWindowParent.Reparent(ParentForm.Handle);
|
||||
ShowBrowser;
|
||||
ResizeBrowser;
|
||||
FMXWindowParent.Show;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -250,6 +254,17 @@ begin
|
||||
if assigned(FOnBrowserClosing) then FOnBrowserClosing(self);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1GotFocus(Sender: TObject;
|
||||
const browser: ICefBrowser);
|
||||
begin
|
||||
// We use a hidden button to fix the focus issues when the browser has the real focus.
|
||||
TThread.Queue(nil,
|
||||
procedure
|
||||
begin
|
||||
FocusWorkaroundBtn.SetFocus;
|
||||
end);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1LoadError(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer;
|
||||
const errorText, failedUrl: ustring);
|
||||
|
@ -81,9 +81,10 @@ type
|
||||
procedure FormResize(Sender: TObject);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
|
||||
procedure BrowserTabCtrlChange(Sender: TObject);
|
||||
|
||||
procedure AddTabActionExecute(Sender: TObject);
|
||||
procedure RemoveTabActionExecute(Sender: TObject);
|
||||
procedure BrowserTabCtrlChange(Sender: TObject);
|
||||
procedure PrevTabActionExecute(Sender: TObject);
|
||||
procedure NextTabActionExecute(Sender: TObject);
|
||||
procedure ShowTabsActionExecute(Sender: TObject);
|
||||
@ -115,8 +116,10 @@ type
|
||||
procedure DestroyTab(aTabID : cardinal);
|
||||
function CloseAllTabs : boolean;
|
||||
procedure CloseSelectedTab;
|
||||
procedure ResizeAllBrowsers;
|
||||
|
||||
property NextTabID : cardinal read GetNextTabID;
|
||||
|
||||
public
|
||||
function PostCustomMessage(aMsg : cardinal; aWParam : WPARAM = 0; aLParam : LPARAM = 0) : boolean;
|
||||
procedure NotifyMoveOrResizeStarted;
|
||||
@ -215,7 +218,9 @@ var
|
||||
PositionChanged: Boolean;
|
||||
begin
|
||||
PositionChanged := (ALeft <> Left) or (ATop <> Top);
|
||||
|
||||
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
|
||||
|
||||
if PositionChanged then
|
||||
NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
@ -241,6 +246,17 @@ begin
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormResize(Sender: TObject);
|
||||
begin
|
||||
ResizeAllBrowsers;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormShow(Sender: TObject);
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and GlobalCEFApp.GlobalContextInitialized then
|
||||
EnableButtonLay;
|
||||
end;
|
||||
|
||||
procedure TMainForm.ResizeAllBrowsers;
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
@ -253,12 +269,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormShow(Sender: TObject);
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and GlobalCEFApp.GlobalContextInitialized then
|
||||
EnableButtonLay;
|
||||
end;
|
||||
|
||||
procedure TMainForm.EnableButtonLay;
|
||||
begin
|
||||
if not(ButtonLay.Enabled) then
|
||||
@ -288,6 +298,8 @@ begin
|
||||
BrowserTabCtrl.TabPosition := TTabPosition.None
|
||||
else
|
||||
BrowserTabCtrl.TabPosition := TTabPosition.PlatformDefault;
|
||||
|
||||
ResizeAllBrowsers;
|
||||
end;
|
||||
|
||||
procedure TMainForm.AddTabActionExecute(Sender: TObject);
|
||||
|
@ -84,8 +84,17 @@ object SimpleFMXBrowserFrm: TSimpleFMXBrowserFrm
|
||||
Size.Height = 565.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 6
|
||||
object FocusWorkaroundBtn: TButton
|
||||
Position.X = 368.000000000000000000
|
||||
Position.Y = 208.000000000000000000
|
||||
Size.Width = 1.000000000000000000
|
||||
Size.Height = 1.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object FMXChromium1: TFMXChromium
|
||||
OnGotFocus = FMXChromium1GotFocus
|
||||
OnBeforeContextMenu = FMXChromium1BeforeContextMenu
|
||||
OnContextMenuCommand = FMXChromium1ContextMenuCommand
|
||||
OnBeforePopup = FMXChromium1BeforePopup
|
||||
|
@ -67,6 +67,7 @@ type
|
||||
GoBtn: TButton;
|
||||
SnapShotBtn: TButton;
|
||||
BrowserLay: TLayout;
|
||||
FocusWorkaroundBtn: TButton;
|
||||
|
||||
procedure GoBtnClick(Sender: TObject);
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
@ -83,6 +84,7 @@ type
|
||||
procedure FMXChromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure FMXChromium1BeforeContextMenu(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel);
|
||||
procedure FMXChromium1ContextMenuCommand(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; commandId: Integer; eventFlags: Cardinal; out Result: Boolean);
|
||||
procedure FMXChromium1GotFocus(Sender: TObject; const browser: ICefBrowser);
|
||||
|
||||
protected
|
||||
// Variables to control when can we destroy the form safely
|
||||
@ -236,6 +238,17 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.FMXChromium1GotFocus(Sender: TObject;
|
||||
const browser: ICefBrowser);
|
||||
begin
|
||||
// We use a hidden button to fix the focus issues when the browser has the real focus.
|
||||
TThread.Queue(nil,
|
||||
procedure
|
||||
begin
|
||||
FocusWorkaroundBtn.SetFocus;
|
||||
end);
|
||||
end;
|
||||
|
||||
function TSimpleFMXBrowserFrm.PostCustomMessage(aMsg : cardinal; aWParam : WPARAM; aLParam : LPARAM) : boolean;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
@ -317,8 +330,7 @@ begin
|
||||
if (FMXWindowParent <> nil) then
|
||||
begin
|
||||
FMXWindowParent.WindowState := TWindowState.wsNormal;
|
||||
FMXWindowParent.Show;
|
||||
FMXWindowParent.SetBounds(GetFMXWindowParentRect);
|
||||
ResizeChild;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 362,
|
||||
"InternalVersion" : 363,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "98.2.1.0"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user