1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-08-04 21:32:54 +02:00

Fixed some focus issues in FMX demos for Windows in normal mode

This commit is contained in:
salvadordf
2022-02-27 19:39:19 +01:00
parent acd6deb308
commit 41490cebdb
6 changed files with 71 additions and 14 deletions

View File

@ -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

View File

@ -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;