From 2081ad570acdc64c9afcc6704639dce206a93b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20D=C3=ADaz=20Fau?= Date: Wed, 12 Feb 2025 10:44:12 +0100 Subject: [PATCH] Block the shortcut to view the HTML source code (Control+U) in MiniBrowser --- demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas | 18 ++++++++++++++---- update_CEF4Delphi.json | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas index 680ba3d1..0a431e94 100644 --- a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas +++ b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas @@ -1118,13 +1118,21 @@ end; procedure TMiniBrowserFrm.Chromium1PreKeyEvent(Sender: TObject; const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out isKeyboardShortcut, Result: Boolean); +const + VK_U = $55; begin Result := False; - if (event <> nil) and - (event.kind in [KEYEVENT_KEYDOWN, KEYEVENT_KEYUP]) and - (event.windows_key_code = VK_F12) then - isKeyboardShortcut := True; + if (event <> nil) then + case event.windows_key_code of + VK_F12 : // Handle the shortcut for the DevTools in Chromium1KeyEvent + if (event.kind in [KEYEVENT_KEYDOWN, KEYEVENT_KEYUP]) then + isKeyboardShortcut := True; + + VK_U : // Block the shortcut to view the HTML source code (Control+U). + if (event.kind in [KEYEVENT_RAWKEYDOWN, KEYEVENT_KEYUP]) then + Result := (event.modifiers and EVENTFLAG_CONTROL_DOWN) <> 0; + end; end; procedure TMiniBrowserFrm.Chromium1RenderCompMsg(Sender: TObject; var aMessage : TMessage; var aHandled: Boolean); @@ -1523,6 +1531,8 @@ begin Chromium1.WebRTCMultipleRoutes := STATE_DISABLED; Chromium1.WebRTCNonproxiedUDP := STATE_DISABLED; + //Chromium1.AcceptLanguageList := 'en-GB,en'; + // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser // If it's not initialized yet, we use a simple timer to create the browser later. if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True; diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 43b3b0a5..6e480f13 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,7 +2,7 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 698, + "InternalVersion" : 699, "Name" : "cef4delphi_lazarus.lpk", "Version" : "132.3.2" }