1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-11-23 21:34:53 +02:00

Fixed TChromium.OnPreKeyEvent and TChromium.OnKeyEvent event parameters in demos

Added a workaround for a focus issue in popup windows handled by CEF in the MiniBrowser demo.
This commit is contained in:
Salvador Diaz Fau
2021-02-03 10:30:07 +01:00
parent e0396ac3a5
commit 12cce1cbba
9 changed files with 106 additions and 42 deletions

View File

@@ -57,10 +57,10 @@ type
Chromium1: TChromium;
Timer1: TTimer;
procedure Chromium1PreKeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out isKeyboardShortcut, Result: Boolean);
procedure Chromium1KeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out Result: Boolean);
procedure FormShow(Sender: TObject);
procedure Chromium1AfterCreated(Sender: TObject;
@@ -204,7 +204,7 @@ begin
end;
procedure TMainForm.Chromium1KeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out Result: Boolean);
var
TempMsg : TMsg;
@@ -230,7 +230,7 @@ begin
end;
procedure TMainForm.Chromium1PreKeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out isKeyboardShortcut, Result: Boolean);
begin
Result := False;

View File

@@ -154,8 +154,8 @@ type
procedure Chromium1StatusMessage(Sender: TObject; const browser: ICefBrowser; const value: ustring);
procedure Chromium1TextResultAvailable(Sender: TObject; const aText: ustring);
procedure Chromium1FullScreenModeChange(Sender: TObject; const browser: ICefBrowser; fullscreen: Boolean);
procedure Chromium1PreKeyEvent(Sender: TObject; const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg; out isKeyboardShortcut, Result: Boolean);
procedure Chromium1KeyEvent(Sender: TObject; const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg; out Result: Boolean);
procedure Chromium1PreKeyEvent(Sender: TObject; const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out isKeyboardShortcut, Result: Boolean);
procedure Chromium1KeyEvent(Sender: TObject; const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out Result: Boolean);
procedure Chromium1ContextMenuCommand(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; commandId: Integer; eventFlags: Cardinal; out Result: Boolean);
procedure Chromium1PdfPrintFinished(Sender: TObject; aResultOK: Boolean);
procedure Chromium1ResourceResponse(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; out Result: Boolean);
@@ -655,7 +655,7 @@ begin
end;
procedure TMiniBrowserFrm.Chromium1KeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out Result: Boolean);
var
TempMsg : TMsg;
@@ -726,13 +726,25 @@ end;
procedure TMiniBrowserFrm.Chromium1LoadEnd(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
httpStatusCode: Integer);
var
TempHandle : THandle;
begin
if (frame = nil) or not(frame.IsValid) then exit;
if FClosing or (frame = nil) or not(frame.IsValid) or (browser = nil) then exit;
if frame.IsMain then
StatusBar1.Panels[1].Text := 'main frame loaded : ' + quotedstr(frame.name)
if Chromium1.IsSameBrowser(browser) then
begin
if frame.IsMain then
StatusBar1.Panels[1].Text := 'main frame loaded : ' + quotedstr(frame.name)
else
StatusBar1.Panels[1].Text := 'frame loaded : ' + quotedstr(frame.name);
end
else
StatusBar1.Panels[1].Text := 'frame loaded : ' + quotedstr(frame.name);
begin
// This is a workaround for a focus issue in popup windows handled by CEF
TempHandle := WinApi.Windows.GetWindow(Browser.Host.WindowHandle, GW_OWNER);
if (TempHandle <> Handle) then
WinApi.Windows.SetFocus(TempHandle);
end;
end;
procedure TMiniBrowserFrm.Chromium1LoadError(Sender: TObject;
@@ -813,7 +825,7 @@ begin
end;
procedure TMiniBrowserFrm.Chromium1PreKeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out isKeyboardShortcut, Result: Boolean);
begin
Result := False;

View File

@@ -67,10 +67,10 @@ type
procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser;
var aAction : TCefCloseBrowserAction);
procedure Chromium1PreKeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out isKeyboardShortcut, Result: Boolean);
procedure Chromium1KeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out Result: Boolean);
procedure Chromium1BeforeClose(Sender: TObject;
const browser: ICefBrowser);
@@ -149,7 +149,7 @@ begin
end;
procedure TChildForm.Chromium1KeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out Result: Boolean);
var
TempMsg : TMsg;
@@ -203,7 +203,7 @@ begin
end;
procedure TChildForm.Chromium1PreKeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out isKeyboardShortcut, Result: Boolean);
begin
Result := False;

View File

@@ -67,10 +67,10 @@ type
procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser;
var aAction : TCefCloseBrowserAction);
procedure Chromium1PreKeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out isKeyboardShortcut, Result: Boolean);
procedure Chromium1KeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out Result: Boolean);
procedure Chromium1BeforeClose(Sender: TObject;
const browser: ICefBrowser);
@@ -149,7 +149,7 @@ begin
end;
procedure TChildForm.Chromium1KeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out Result: Boolean);
var
TempMsg : TMsg;
@@ -203,7 +203,7 @@ begin
end;
procedure TChildForm.Chromium1PreKeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle;
out isKeyboardShortcut, Result: Boolean);
begin
Result := False;