Block F1 and F11 in MiniBrowser demos

This commit is contained in:
Salvador Díaz Fau 2024-09-12 09:05:07 +02:00
parent a42f3dfd5f
commit b5e337f36c
10 changed files with 47 additions and 11 deletions

View File

@ -312,6 +312,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
OnResourceResponse = Chromium1ResourceResponse
OnFileDialog = Chromium1FileDialog
OnDevToolsMethodResult = Chromium1DevToolsMethodResult
OnChromeCommand = Chromium1ChromeCommand
OnRequestMediaAccessPermission = Chromium1RequestMediaAccessPermission
Left = 32
Top = 224

View File

@ -175,6 +175,7 @@ type
procedure Chromium1FileDialog(Sender: TObject; const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; const acceptFilters, accept_extensions, accept_descriptions: TStrings; const callback: ICefFileDialogCallback; var Result: Boolean);
procedure Chromium1LoadError(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; errorCode: TCefErrorCode; const errorText, failedUrl: ustring);
procedure Chromium1ResolvedHostAvailable(Sender: TObject; result: TCefErrorCode; const resolvedIps: TStrings);
procedure Chromium1ChromeCommand(Sender: TObject; const browser: ICefBrowser; command_id: Integer; disposition: TCefWindowOpenDisposition; var aResult: Boolean);
procedure BackBtnClick(Sender: TObject);
procedure ForwardBtnClick(Sender: TObject);
@ -553,6 +554,14 @@ begin
Result := False;
end;
procedure TMiniBrowserFrm.Chromium1ChromeCommand(Sender: TObject;
const browser: ICefBrowser; command_id: Integer;
disposition: TCefWindowOpenDisposition; var aResult: Boolean);
begin
aResult := (command_id = IDC_HELP_PAGE_VIA_KEYBOARD) or // Block the new Chromium window created when the user presses F1 for help.
(command_id = IDC_FULLSCREEN); // Block the "switch to full screen" command when the user presses F11.
end;
procedure TMiniBrowserFrm.Chromium1ConsoleMessage(Sender: TObject;
const browser: ICefBrowser; level: TCefLogSeverity;
const message_, source: ustring; line: Integer; out Result: Boolean);

Binary file not shown.

View File

@ -264,6 +264,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
OnAfterCreated = Chromium1AfterCreated
OnBeforeClose = Chromium1BeforeClose
OnClose = Chromium1Close
OnChromeCommand = Chromium1ChromeCommand
Left = 32
Top = 224
end

View File

@ -57,7 +57,8 @@ type
procedure Chromium1LoadEnd(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer);
procedure Chromium1LoadError(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; errorCode: TCefErrorCode; const errorText, failedUrl: ustring);
procedure Chromium1StatusMessage(Sender: TObject; const browser: ICefBrowser; const value: ustring);
procedure Chromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring);
procedure Chromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring);
procedure Chromium1ChromeCommand(Sender: TObject; const browser: ICefBrowser; command_id: Integer; disposition: TCefWindowOpenDisposition; var aResult: Boolean);
procedure BackBtnClick(Sender: TObject);
procedure ConfigBtnClick(Sender: TObject);
@ -320,10 +321,7 @@ begin
// if TChromium.MultiBrowserMode is enabled then we have to close all
// stored browsers and not only the main browser.
Chromium1.CloseAllBrowsers;
// Workaround for the missing TChormium.OnClose event when "Chrome runtime" is enabled.
if GlobalCEFApp.ChromeRuntime then
CEFWindowParent1.Free;
CEFWindowParent1.Free;
end;
end;
@ -341,7 +339,6 @@ begin
// used when you call any method or property in TChromium.
Chromium1.MultiBrowserMode := True;
Chromium1.DefaultURL := MINIBROWSER_HOMEPAGE;
Chromium1.RuntimeStyle := CEF_RUNTIME_STYLE_ALLOY;
end;
procedure TMiniBrowserFrm.FormShow(Sender: TObject);
@ -412,4 +409,12 @@ begin
GlobalCEFApp.OsmodalLoop := False;
end;
procedure TMiniBrowserFrm.Chromium1ChromeCommand(Sender: TObject;
const browser: ICefBrowser; command_id: Integer;
disposition: TCefWindowOpenDisposition; var aResult: Boolean);
begin
aResult := (command_id = IDC_HELP_PAGE_VIA_KEYBOARD) or // Block the new Chromium window created when the user presses F1 for help.
(command_id = IDC_FULLSCREEN); // Block the "switch to full screen" command when the user presses F11.
end;
end.

View File

@ -15,7 +15,6 @@ object MiniBrowserFrm: TMiniBrowserFrm
OnCreate = FormCreate
OnDestroy = FormDestroy
Position = poScreenCenter
LCLVersion = '3.4.0.0'
object NavControlPnl: TPanel
Left = 0
Height = 25
@ -250,6 +249,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
OnPrintJob = Chromium1PrintJob
OnPrintReset = Chromium1PrintReset
OnGetPDFPaperSize = Chromium1GetPDFPaperSize
OnChromeCommand = Chromium1ChromeCommand
Left = 32
Top = 224
end

View File

@ -59,6 +59,7 @@ type
OpenfilewithaDAT1: TMenuItem;
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
procedure Chromium1ChromeCommand(Sender: TObject; const browser: ICefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition; var aResult: boolean);
procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
procedure Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
procedure Chromium1GetPDFPaperSize(Sender: TObject; const browser: ICefBrowser; deviceUnitsPerInch: Integer; var aResult: TCefSize);
@ -620,6 +621,14 @@ begin
SendCompMessage(CEF_AFTERCREATED);
end;
procedure TMiniBrowserFrm.Chromium1ChromeCommand(Sender: TObject;
const browser: ICefBrowser; command_id: integer;
disposition: TCefWindowOpenDisposition; var aResult: boolean);
begin
aResult := (command_id = IDC_HELP_PAGE_VIA_KEYBOARD) or // Block the new Chromium window created when the user presses F1 for help.
(command_id = IDC_FULLSCREEN); // Block the "switch to full screen" command when the user presses F11.
end;
procedure TMiniBrowserFrm.Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
begin
// The main browser is being destroyed

View File

@ -15,6 +15,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
OnDestroy = FormDestroy
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '3.4.0.0'
object Splitter1: TSplitter
Left = 1179
Height = 663
@ -117,11 +118,11 @@ object MiniBrowserFrm: TMiniBrowserFrm
TabOrder = 1
object URLCbx: TComboBox
Left = 0
Height = 22
Height = 21
Top = 3
Width = 978
Anchors = [akTop, akLeft, akRight, akBottom]
ItemHeight = 14
ItemHeight = 13
ItemIndex = 0
Items.Strings = (
'https://www.google.com'
@ -274,6 +275,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
OnBeforeResourceLoad = Chromium1BeforeResourceLoad
OnResourceResponse = Chromium1ResourceResponse
OnDevToolsMethodResult = Chromium1DevToolsMethodResult
OnChromeCommand = Chromium1ChromeCommand
OnRequestMediaAccessPermission = Chromium1RequestMediaAccessPermission
Left = 32
Top = 224

View File

@ -118,7 +118,7 @@ type
N5: TMenuItem;
Memoryinfo1: TMenuItem;
procedure FormShow(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
@ -186,6 +186,7 @@ type
procedure Chromium1LoadError(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring);
procedure Chromium1CertificateError(Sender: TObject; const browser: ICefBrowser; certError: Integer; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefCallback; out Result: Boolean);
procedure Chromium1NavigationVisitorResultAvailable(Sender: TObject; const entry: ICefNavigationEntry; current: Boolean; index, total: Integer; var aResult: Boolean);
procedure Chromium1ChromeCommand(Sender: TObject; const browser: ICefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition; var aResult: boolean);
protected
FResponse : TStringList;
@ -1142,6 +1143,14 @@ begin
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TMiniBrowserFrm.Chromium1ChromeCommand(Sender: TObject;
const browser: ICefBrowser; command_id: integer;
disposition: TCefWindowOpenDisposition; var aResult: boolean);
begin
aResult := (command_id = IDC_HELP_PAGE_VIA_KEYBOARD) or // Block the new Chromium window created when the user presses F1 for help.
(command_id = IDC_FULLSCREEN); // Block the "switch to full screen" command when the user presses F11.
end;
procedure TMiniBrowserFrm.Chromium1CookiesFlushed(Sender: TObject);
begin
PostMessage(Handle, MINIBROWSER_COOKIESFLUSHED, 0, 0);

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 653,
"InternalVersion" : 654,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "128.4.9"
}