1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2024-11-24 08:02:15 +02:00

Added touch gestures to the KioskOSRBrowser demo

- Removed TCEFSentinel from the KioskOSRBrowser demo
- Added the -dUseCThreads compiler option to the Lazarus demos in Linux.
- Replaced panel by TLayout in the SimpleFMXBrowser demo.
This commit is contained in:
Salvador Díaz Fau 2020-02-01 17:04:19 +01:00
parent 23663b10e2
commit 64d9393439
12 changed files with 674 additions and 111 deletions

View File

@ -33,7 +33,7 @@ object SimpleFMXBrowserFrm: TSimpleFMXBrowserFrm
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
end
object Panel1: TPanel
object Layout1: TLayout
Align = Right
Padding.Left = 5.000000000000000000
Position.X = 830.000000000000000000
@ -41,7 +41,7 @@ object SimpleFMXBrowserFrm: TSimpleFMXBrowserFrm
Size.Width = 82.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
TabOrder = 2
TabOrder = 3
object GoBtn: TButton
Align = Left
Position.X = 5.000000000000000000

View File

@ -48,7 +48,7 @@ uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.Edit, FMX.Controls.Presentation, uCEFFMXWindowParent, uCEFFMXChromium,
uCEFInterfaces, uCEFConstants, uCEFTypes, uCEFChromiumCore;
uCEFInterfaces, uCEFConstants, uCEFTypes, uCEFChromiumCore, FMX.Layouts;
const
MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS = MENU_ID_USER_FIRST + 1;
@ -61,10 +61,10 @@ type
AddressEdt: TEdit;
FMXChromium1: TFMXChromium;
Timer1: TTimer;
Panel1: TPanel;
SaveDialog1: TSaveDialog;
Layout1: TLayout;
GoBtn: TButton;
SnapShotBtn: TButton;
SaveDialog1: TSaveDialog;
procedure GoBtnClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);

View File

@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{7DC52040-59FF-4430-BF65-3A852AB5A6C0}</ProjectGuid>
<ProjectVersion>18.5</ProjectVersion>
<ProjectVersion>18.8</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<MainSource>KioskOSRBrowser.dpr</MainSource>
<Base>True</Base>
@ -186,12 +186,20 @@
<RemoteDir>classes</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>classes</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidFileProvider">
<Platform Name="Android">
<RemoteDir>res\xml</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\xml</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidGDBServer">
<Platform Name="Android">
@ -204,96 +212,242 @@
<RemoteDir>library\lib\armeabi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeArmeabiv7aFile">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeMipsFile">
<Platform Name="Android">
<RemoteDir>library\lib\mips</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\mips</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidServiceOutput">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\arm64-v8a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidServiceOutput_Android32">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashImageDef">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashStyles">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashStylesV21">
<Platform Name="Android">
<RemoteDir>res\values-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_Colors">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_DefaultAppIcon">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon144">
<Platform Name="Android">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon36">
<Platform Name="Android">
<RemoteDir>res\drawable-ldpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-ldpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon48">
<Platform Name="Android">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon72">
<Platform Name="Android">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon96">
<Platform Name="Android">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon24">
<Platform Name="Android">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon36">
<Platform Name="Android">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon48">
<Platform Name="Android">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon72">
<Platform Name="Android">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon96">
<Platform Name="Android">
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage426">
<Platform Name="Android">
<RemoteDir>res\drawable-small</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-small</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage470">
<Platform Name="Android">
<RemoteDir>res\drawable-normal</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-normal</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage640">
<Platform Name="Android">
<RemoteDir>res\drawable-large</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-large</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage960">
<Platform Name="Android">
<RemoteDir>res\drawable-xlarge</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xlarge</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_Strings">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="DebugSymbols">
<Platform Name="iOSSimulator">
@ -382,6 +536,9 @@
<Platform Name="Android">
<Operation>0</Operation>
</Platform>
<Platform Name="Android64">
<Operation>0</Operation>
</Platform>
<Platform Name="iOSDevice32">
<Operation>0</Operation>
</Platform>
@ -414,6 +571,17 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1024x768">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1536">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
@ -425,6 +593,39 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1536x2048">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1668">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1668x2388">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2048">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
@ -436,6 +637,61 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2048x1536">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2048x2732">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2224">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2388x1668">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2732x2048">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch768">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
@ -447,6 +703,116 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch768x1024">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1125">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1136x640">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1242">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1242x2688">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1334">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1792">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch2208">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch2436">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch2688x1242">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch320">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
@ -480,10 +846,35 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch750">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch828">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectAndroidManifest">
<Platform Name="Android">
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceDebug">
<Platform Name="iOSDevice32">
@ -576,6 +967,10 @@
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\arm64-v8a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
@ -600,6 +995,12 @@
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOutput_Android32">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectUWPManifest">
<Platform Name="Win32">
<Operation>1</Operation>
@ -637,6 +1038,7 @@
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
</Deployment>
<Platforms>
<Platform value="Win32">True</Platform>

View File

@ -39,6 +39,8 @@ object Form1: TForm1
OnMouseUp = Panel1MouseUp
OnResize = Panel1Resize
OnMouseLeave = Panel1MouseLeave
Touch.GestureManager = GestureManager1
OnGesture = Panel1Gesture
end
object TouchKeyboard1: TTouchKeyboard
Left = 0
@ -65,24 +67,34 @@ object Form1: TForm1
OnPaint = chrmosrPaint
OnCursorChange = chrmosrCursorChange
OnVirtualKeyboardRequested = chrmosrVirtualKeyboardRequested
Left = 24
Top = 56
Left = 40
Top = 40
end
object AppEvents: TApplicationEvents
OnMessage = AppEventsMessage
Left = 24
Top = 128
Left = 40
Top = 112
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 24
Top = 206
Left = 40
Top = 182
end
object CEFSentinel1: TCEFSentinel
OnClose = CEFSentinel1Close
Left = 24
Top = 280
object GestureManager1: TGestureManager
Left = 40
Top = 256
GestureData = <
item
Control = Panel1
Collection = <
item
GestureID = sgiLeft
end
item
GestureID = sgiRight
end>
end>
end
end

View File

@ -51,7 +51,7 @@ uses
Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, AppEvnts, Keyboard,
{$ENDIF}
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel,
uCEFSentinel;
uCEFSentinel, uCEFChromiumCore, Vcl.Touch.GestureMgr;
const
HOMEPAGE_URL = 'https://www.google.com';
@ -73,11 +73,10 @@ type
Timer1: TTimer;
Panel1: TBufferPanel;
TouchKeyboard1: TTouchKeyboard;
CEFSentinel1: TCEFSentinel;
GestureManager1: TGestureManager;
procedure AppEventsMessage(var Msg: tagMSG; var Handled: Boolean);
procedure Timer1Timer(Sender: TObject);
procedure CEFSentinel1Close(Sender: TObject);
procedure Panel1Enter(Sender: TObject);
procedure Panel1Exit(Sender: TObject);
@ -108,6 +107,8 @@ type
procedure chrmosrBeforeContextMenu(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel);
procedure chrmosrContextMenuCommand(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; commandId: Integer; eventFlags: Cardinal; out Result: Boolean);
procedure chrmosrVirtualKeyboardRequested(Sender: TObject; const browser: ICefBrowser; input_mode: TCefTextInpuMode);
procedure Panel1Gesture(Sender: TObject; const EventInfo: TGestureEventInfo;
var Handled: Boolean);
protected
FPopUpBitmap : TBitmap;
@ -170,8 +171,7 @@ uses
// 2- chrmosr.CloseBrowser(True) will trigger chrmosr.OnClose and we have to
// set "Result" to false and CEF will destroy the internal browser immediately.
// 3- chrmosr.OnBeforeClose is triggered because the internal browser was destroyed.
// Now we call TCEFSentinel.Start, which will trigger TCEFSentinel.OnClose when the renderer processes are closed.
// 4- TCEFSentinel.OnClose sets FCanClose := True and sends WM_CLOSE to the form.
// It sets FCanClose := True and sends WM_CLOSE to the form.
procedure CreateGlobalCEFApp;
begin
@ -303,7 +303,8 @@ end;
procedure TForm1.chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
begin
CEFSentinel1.Start;
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
procedure TForm1.chrmosrBeforeContextMenu( Sender : TObject;
@ -864,12 +865,6 @@ begin
(cardinal(aCurrentTime - FLastClickTime) > GetDoubleClickTime);
end;
procedure TForm1.CEFSentinel1Close(Sender: TObject);
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
procedure TForm1.Panel1Enter(Sender: TObject);
begin
chrmosr.SendFocusEvent(True);
@ -881,6 +876,15 @@ begin
chrmosr.SendFocusEvent(False);
end;
procedure TForm1.Panel1Gesture(Sender: TObject;
const EventInfo: TGestureEventInfo; var Handled: Boolean);
begin
case EventInfo.GestureID of
sgiLeft : chrmosr.GoBack;
sgiRight : chrmosr.GoForward;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;

View File

@ -64,6 +64,9 @@
</Win32>
</Options>
</Linking>
<Other>
<CustomOptions Value="-dUseCthreads"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">

View File

@ -3,15 +3,14 @@
<ProjectSession>
<Version Value="11"/>
<BuildModes Active="Default"/>
<Units Count="7">
<Units Count="11">
<Unit0>
<Filename Value="SimpleBrowser2.lpr"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="34"/>
<CursorPos Y="37"/>
<UsageCount Value="21"/>
<CursorPos Y="56"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -21,9 +20,10 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleBrowser2"/>
<TopLine Value="95"/>
<CursorPos X="6" Y="141"/>
<UsageCount Value="21"/>
<IsVisibleTab Value="True"/>
<TopLine Value="122"/>
<CursorPos X="30" Y="139"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@ -37,8 +37,8 @@
<Unit3>
<Filename Value="../../../../source/uCEFApplicationCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1950"/>
<CursorPos X="62" Y="1973"/>
<TopLine Value="891"/>
<CursorPos X="63" Y="1021"/>
<UsageCount Value="10"/>
</Unit3>
<Unit4>
@ -52,8 +52,8 @@
<Unit5>
<Filename Value="../../../../source/uCEFMiscFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1100"/>
<CursorPos Y="1120"/>
<TopLine Value="1025"/>
<CursorPos X="80" Y="1040"/>
<UsageCount Value="10"/>
</Unit5>
<Unit6>
@ -63,11 +63,110 @@
<CursorPos X="127" Y="1047"/>
<UsageCount Value="10"/>
</Unit6>
<Unit7>
<Filename Value="../../../../source/uCEFChromium.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="284"/>
<CursorPos Y="312"/>
<UsageCount Value="10"/>
</Unit7>
<Unit8>
<Filename Value="../../../../source/uCEFChromiumCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="4369"/>
<CursorPos X="40" Y="4378"/>
<UsageCount Value="10"/>
</Unit8>
<Unit9>
<Filename Value="/usr/share/fpcsrc/3.0.4/rtl/objpas/classes/classesh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="1556"/>
<CursorPos X="3" Y="1573"/>
<UsageCount Value="10"/>
</Unit9>
<Unit10>
<Filename Value="/usr/share/fpcsrc/3.0.4/rtl/objpas/sysutils/osutilsh.inc"/>
<EditorIndex Value="-1"/>
<CursorPos X="10" Y="26"/>
<UsageCount Value="10"/>
</Unit10>
</Units>
<JumpHistory HistoryIndex="-1"/>
<JumpHistory Count="15" HistoryIndex="14">
<Position1>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="211" Column="39" TopLine="201"/>
</Position1>
<Position2>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="211" Column="7" TopLine="194"/>
</Position2>
<Position3>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="216" Column="44" TopLine="194"/>
</Position3>
<Position4>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="91" Column="15" TopLine="67"/>
</Position4>
<Position5>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="212" Column="32" TopLine="195"/>
</Position5>
<Position6>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="212" Column="22" TopLine="195"/>
</Position6>
<Position7>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="88" Column="15" TopLine="72"/>
</Position7>
<Position8>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="137" Column="3" TopLine="132"/>
</Position8>
<Position9>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="136" TopLine="117"/>
</Position9>
<Position10>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="137" TopLine="117"/>
</Position10>
<Position11>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="138" TopLine="117"/>
</Position11>
<Position12>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="140" TopLine="117"/>
</Position12>
<Position13>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="142" TopLine="117"/>
</Position13>
<Position14>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="143" TopLine="117"/>
</Position14>
<Position15>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="144" TopLine="117"/>
</Position15>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0" ActiveMode=""/>
</RunParams>
</ProjectSession>
<Debugging>
<BreakPoints Count="1">
<Item1>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="../../../../source/uCEFChromiumCore.pas"/>
<Line Value="4373"/>
</Item1>
</BreakPoints>
</Debugging>
</CONFIG>

View File

@ -87,7 +87,7 @@ type
function SendCompMessage(aMsg : cardinal) : boolean;
procedure BrowserCreatedMsg(Data: PtrInt);
procedure BrowserCreated;
procedure BrowserDestroyMsg(Data: PtrInt);
procedure BrowserCloseFormMsg(Data: PtrInt);
public
@ -130,15 +130,25 @@ uses
procedure CreateGlobalCEFApp;
var
TempHome, TempBinDir : ustring;
begin
GlobalCEFApp := TCefApplication.Create;
{
GlobalCEFApp.FrameworkDirPath := '/home/username/Lazarus/CEF4Delphi/bin';
GlobalCEFApp.ResourcesDirPath := '/home/username/Lazarus/CEF4Delphi/bin';
GlobalCEFApp.LocalesDirPath := '/home/username/Lazarus/CEF4Delphi/bin/locales';
GlobalCEFApp.LogFile := 'cef.log';
GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
}
TempHome := IncludeTrailingPathDelimiter(GetEnvironmentVariable('HOME'));
TempBinDir := TempHome + 'Lazarus/CEF4Delphi/bin';
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.SetCurrentDir := True;
if DirectoryExists(TempBinDir) then
begin
GlobalCEFApp.FrameworkDirPath := TempBinDir;
GlobalCEFApp.ResourcesDirPath := TempBinDir;
GlobalCEFApp.LocalesDirPath := TempBinDir + '/locales';
end;
// Add a debug log in the BIN directory
GlobalCEFApp.LogFile := 'cef.log';
GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
end;
procedure TForm1.FormCreate(Sender: TObject);
@ -148,7 +158,9 @@ begin
end;
procedure TForm1.FormShow(Sender: TObject);
begin
begin
Chromium1.DefaultURL := UTF8Decode(AddressEdt.Text);
// You *MUST* call CreateBrowser to create and initialize the browser.
// This will trigger the AfterCreated event when the browser is fully
// initialized and ready to receive commands.
@ -205,8 +217,14 @@ end;
procedure TForm1.Chromium1AfterCreated(Sender: TObject;
const browser: ICefBrowser);
begin
// Now the browser is fully initialized we can send a message to the main form to load the initial web page.
SendCompMessage(CEF_AFTERCREATED);
// Now the browser is fully initialized we can initialize the UI.
TThread.Queue(nil, @BrowserCreated);
end;
procedure TForm1.BrowserCreated;
begin
Caption := 'Simple Browser 2';
AddressPnl.Enabled := True;
end;
procedure TForm1.Chromium1BeforeClose(Sender: TObject;
@ -225,13 +243,6 @@ begin
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
end;
procedure TForm1.BrowserCreatedMsg(Data: PtrInt);
begin
Caption := 'Simple Browser 2';
AddressPnl.Enabled := True;
GoBtn.Click;
end;
procedure TForm1.BrowserDestroyMsg(Data: PtrInt);
begin
CEFWindowParent1.Free;
@ -245,7 +256,6 @@ end;
function TForm1.SendCompMessage(aMsg : cardinal) : boolean;
begin
case aMsg of
CEF_AFTERCREATED : Application.QueueAsyncCall(@BrowserCreatedMsg, 0);
CEF_DESTROY : Application.QueueAsyncCall(@BrowserDestroyMsg, 0);
CEF_BEFORECLOSE : Application.QueueAsyncCall(@BrowserCloseFormMsg, 0);
end;

View File

@ -64,6 +64,9 @@
</Win32>
</Options>
</Linking>
<Other>
<CustomOptions Value="-dUseCthreads"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">

View File

@ -3,14 +3,14 @@
<ProjectSession>
<Version Value="11"/>
<BuildModes Active="Default"/>
<Units Count="4">
<Units Count="5">
<Unit0>
<Filename Value="SimpleOSRBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="16"/>
<CursorPos Y="37"/>
<UsageCount Value="21"/>
<EditorIndex Value="2"/>
<TopLine Value="31"/>
<CursorPos X="56" Y="52"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -21,9 +21,10 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleOSRBrowser"/>
<IsVisibleTab Value="True"/>
<TopLine Value="205"/>
<CursorPos X="67" Y="209"/>
<UsageCount Value="21"/>
<TopLine Value="153"/>
<CursorPos X="65" Y="176"/>
<ComponentState Value="1"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@ -42,116 +43,136 @@
<CursorPos X="27" Y="1907"/>
<UsageCount Value="10"/>
</Unit3>
<Unit4>
<Filename Value="../../../../source/uCEFApplicationCore.pas"/>
<EditorIndex Value="1"/>
<TopLine Value="432"/>
<CursorPos X="29" Y="445"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit4>
</Units>
<JumpHistory Count="27" HistoryIndex="26">
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="49" Column="52" TopLine="34"/>
<Caret Line="584" Column="18" TopLine="567"/>
</Position1>
<Position2>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="186" Column="13" TopLine="169"/>
<Caret Line="710" Column="5" TopLine="688"/>
</Position2>
<Position3>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="133" Column="5" TopLine="117"/>
<Caret Line="776" Column="43" TopLine="751"/>
</Position3>
<Position4>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="46" Column="28" TopLine="23"/>
<Caret Line="147" Column="34" TopLine="132"/>
</Position4>
<Position5>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="191" Column="31" TopLine="187"/>
<Caret Line="300" Column="33" TopLine="284"/>
</Position5>
<Position6>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="209" Column="45" TopLine="191"/>
<Caret Line="328" Column="29" TopLine="309"/>
</Position6>
<Position7>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="167" Column="21" TopLine="151"/>
<Caret Line="771" Column="48" TopLine="751"/>
</Position7>
<Position8>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="214" Column="69" TopLine="197"/>
<Caret Line="774" TopLine="742"/>
</Position8>
<Position9>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="303" Column="45" TopLine="282"/>
<Caret Line="135" Column="34" TopLine="132"/>
</Position9>
<Position10>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="327" Column="29" TopLine="299"/>
<Caret Line="294" Column="7" TopLine="281"/>
</Position10>
<Position11>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="774" Column="45" TopLine="757"/>
<Caret Line="141" TopLine="122"/>
</Position11>
<Position12>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="147" Column="15" TopLine="131"/>
<Caret Line="297" Column="76" TopLine="277"/>
</Position12>
<Position13>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="584" Column="18" TopLine="567"/>
<Caret Line="328" Column="75" TopLine="311"/>
</Position13>
<Position14>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="710" Column="5" TopLine="688"/>
<Caret Line="641" TopLine="625"/>
</Position14>
<Position15>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="776" Column="43" TopLine="751"/>
<Caret Line="740" Column="10" TopLine="710"/>
</Position15>
<Position16>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="147" Column="34" TopLine="132"/>
<Caret Line="142" Column="30" TopLine="172"/>
</Position16>
<Position17>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="300" Column="33" TopLine="284"/>
<Caret Line="712" Column="61" TopLine="612"/>
</Position17>
<Position18>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="328" Column="29" TopLine="309"/>
<Caret Line="725" Column="41" TopLine="705"/>
</Position18>
<Position19>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="771" Column="48" TopLine="751"/>
<Caret Line="726" Column="20" TopLine="705"/>
</Position19>
<Position20>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="774" TopLine="742"/>
<Caret Line="388" Column="34" TopLine="368"/>
</Position20>
<Position21>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="135" Column="34" TopLine="132"/>
<Caret Line="726" Column="20" TopLine="694"/>
</Position21>
<Position22>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="294" Column="7" TopLine="281"/>
<Caret Line="388" TopLine="161"/>
</Position22>
<Position23>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="141" TopLine="122"/>
<Caret Line="674" TopLine="649"/>
</Position23>
<Position24>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="297" Column="76" TopLine="277"/>
<Caret Line="79" Column="33" TopLine="70"/>
</Position24>
<Position25>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="328" Column="75" TopLine="311"/>
<Caret Line="203" TopLine="198"/>
</Position25>
<Position26>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="641" TopLine="625"/>
<Caret Line="674" TopLine="654"/>
</Position26>
<Position27>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="740" Column="10" TopLine="710"/>
<Caret Line="682" TopLine="654"/>
</Position27>
<Position28>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="683" TopLine="654"/>
</Position28>
<Position29>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="181" Column="6" TopLine="155"/>
</Position29>
<Position30>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="183" Column="63" TopLine="155"/>
</Position30>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>

View File

@ -139,7 +139,7 @@ type
function GetButton(Button: TMouseButton): TCefMouseButtonType;
procedure DoResize;
procedure BrowserCreatedMsg(Data: PtrInt);
procedure BrowserCreated;
procedure BrowserCloseFormMsg(Data: PtrInt);
procedure PendingResizeMsg(Data: PtrInt);
procedure PendingInvalidateMsg(Data: PtrInt);
@ -161,17 +161,27 @@ uses
uCEFMiscFunctions, uCEFApplication;
procedure CreateGlobalCEFApp;
var
TempHome, TempBinDir : ustring;
begin
TempHome := IncludeTrailingPathDelimiter(GetEnvironmentVariable('HOME'));
TempBinDir := TempHome + 'Lazarus/CEF4Delphi/bin';
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.WindowlessRenderingEnabled := True;
GlobalCEFApp.EnableHighDPISupport := True;
{
GlobalCEFApp.FrameworkDirPath := '/home/username/Lazarus/CEF4Delphi/bin';
GlobalCEFApp.ResourcesDirPath := '/home/username/Lazarus/CEF4Delphi/bin';
GlobalCEFApp.LocalesDirPath := '/home/username/Lazarus/CEF4Delphi/bin/locales';
GlobalCEFApp.LogFile := 'cef.log';
GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
}
GlobalCEFApp.SetCurrentDir := True;
if DirectoryExists(TempBinDir) then
begin
GlobalCEFApp.FrameworkDirPath := TempBinDir;
GlobalCEFApp.ResourcesDirPath := TempBinDir;
GlobalCEFApp.LocalesDirPath := TempBinDir + '/locales';
end;
// Add a debug log in the BIN directory
GlobalCEFApp.LogFile := 'cef.log';
GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
end;
{ TForm1 }
@ -189,8 +199,8 @@ end;
procedure TForm1.Chromium1AfterCreated(Sender: TObject;
const browser: ICefBrowser);
begin
// Now the browser is fully initialized we can send a message to the main form to load the initial web page.
SendCompMessage(CEF_AFTERCREATED);
// Now the browser is fully initialized we can initialize the UI.
TThread.Queue(nil, @BrowserCreated);
end;
procedure TForm1.Panel1UTF8KeyPress(Sender: TObject;
@ -669,7 +679,8 @@ begin
else
begin
// opaque white background color
Chromium1.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
Chromium1.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
Chromium1.DefaultURL := UTF8Decode(AddressEdt.Text);
if not(Chromium1.CreateBrowser(nil, '')) then Timer1.Enabled := True;
end;
@ -688,11 +699,10 @@ begin
Timer1.Enabled := True;
end;
procedure TForm1.BrowserCreatedMsg(Data: PtrInt);
procedure TForm1.BrowserCreated;
begin
Caption := 'Simple OSR Browser';
AddressPnl.Enabled := True;
GoBtn.Click;
end;
procedure TForm1.BrowserCloseFormMsg(Data: PtrInt);
@ -713,7 +723,6 @@ end;
function TForm1.SendCompMessage(aMsg : cardinal) : boolean;
begin
case aMsg of
CEF_AFTERCREATED : Application.QueueAsyncCall(@BrowserCreatedMsg, 0);
CEF_BEFORECLOSE : Application.QueueAsyncCall(@BrowserCloseFormMsg, 0);
CEF_PENDINGRESIZE : Application.QueueAsyncCall(@PendingResizeMsg, 0);
CEF_PENDINGINVALIDATE : Application.QueueAsyncCall(@PendingInvalidateMsg, 0);

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 86,
"InternalVersion" : 87,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "79.1.36.0"
}