You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-12-13 21:45:55 +02:00
Added KioskBrowser for Lazarus
Fixed issue #565: TTouchKeyboard doesn't work in the KioskBrowser demo while running in Windows 11
This commit is contained in:
@@ -5,15 +5,11 @@ unit uKioskBrowser;
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
||||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
|
||||
{$ELSE}
|
||||
Windows, Messages, SysUtils, Variants, Classes, Graphics,
|
||||
Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
|
||||
{$ENDIF}
|
||||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
||||
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
|
||||
Vcl.StdCtrls, Vcl.ExtCtrls,
|
||||
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFConstants, uCEFTypes,
|
||||
uCEFWinControl, uCEFChromiumCore, Vcl.Touch.Keyboard;
|
||||
uCEFWinControl, uCEFChromiumCore, uVirtualTouchKeyboard;
|
||||
|
||||
const
|
||||
HOMEPAGE_URL = 'https://www.google.com';
|
||||
@@ -33,12 +29,12 @@ type
|
||||
Timer1: TTimer;
|
||||
Chromium1: TChromium;
|
||||
CEFWindowParent1: TCEFWindowParent;
|
||||
TouchKeyboard1: TTouchKeyboard;
|
||||
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
|
||||
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
@@ -57,6 +53,8 @@ type
|
||||
FCanClose : boolean; // Set to True in TChromium.OnBeforeClose
|
||||
FClosing : boolean; // Set to True in the CloseQuery event.
|
||||
|
||||
FVirtualTouchKeyboard : TVirtualTouchKeyboard;
|
||||
|
||||
procedure HandleKeyUp(const aMsg : TMsg; var aHandled : boolean);
|
||||
procedure HandleKeyDown(const aMsg : TMsg; var aHandled : boolean);
|
||||
|
||||
@@ -164,6 +162,7 @@ begin
|
||||
GlobalCEFApp.RootCache := 'RootCache';
|
||||
GlobalCEFApp.EnablePrintPreview := True;
|
||||
GlobalCEFApp.TouchEvents := STATE_ENABLED;
|
||||
GlobalCEFApp.AddCustomCommandLine('--kiosk');
|
||||
GlobalCEFApp.EnableGPU := True;
|
||||
{$IFDEF DEBUG}
|
||||
GlobalCEFApp.LogFile := 'debug.log';
|
||||
@@ -201,13 +200,19 @@ begin
|
||||
FCanClose := False;
|
||||
FClosing := False;
|
||||
Chromium1.DefaultURL := HOMEPAGE_URL;
|
||||
FVirtualTouchKeyboard := TVirtualTouchKeyboard.Create;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FVirtualTouchKeyboard.Free;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormShow(Sender: TObject);
|
||||
begin
|
||||
// We use a normal form while debugging.
|
||||
{$IFNDEF DEBUG}
|
||||
self.Position := wsMaximized;
|
||||
self.WindowState := wsMaximized;
|
||||
{$ENDIF}
|
||||
|
||||
// You *MUST* call CreateBrowser to create and initialize the browser.
|
||||
@@ -238,7 +243,7 @@ procedure TForm1.Chromium1BeforeContextMenu(Sender: TObject;
|
||||
begin
|
||||
model.AddSeparator;
|
||||
|
||||
if TouchKeyboard1.Visible then
|
||||
if FVirtualTouchKeyboard.Visible then
|
||||
model.AddItem(KIOSKBROWSER_CONTEXTMENU_HIDEKEYBOARD, 'Hide virtual keyboard')
|
||||
else
|
||||
model.AddItem(KIOSKBROWSER_CONTEXTMENU_SHOWKEYBOARD, 'Show virtual keyboard');
|
||||
@@ -390,12 +395,12 @@ end;
|
||||
|
||||
procedure TForm1.ShowKeyboardMsg(var aMessage : TMessage);
|
||||
begin
|
||||
TouchKeyboard1.Visible := True;
|
||||
FVirtualTouchKeyboard.Show;
|
||||
end;
|
||||
|
||||
procedure TForm1.HideKeyboardMsg(var aMessage : TMessage);
|
||||
begin
|
||||
TouchKeyboard1.Visible := False;
|
||||
FVirtualTouchKeyboard.Hide;
|
||||
end;
|
||||
|
||||
procedure TForm1.FocusEnabledMsg(var aMessage : TMessage);
|
||||
|
||||
Reference in New Issue
Block a user