You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-11-23 21:34:53 +02:00
Added MobileBrowser demo for Lazarus on Windows and Linux
Fixed issues using the message_id parameter incorrectly when calling ExecuteDevToolsMethod in the MiniBrowser and MobileBrowser demos.
This commit is contained in:
@@ -110,6 +110,8 @@ type
|
||||
FCanClose : boolean; // Set to True in TChromium.OnBeforeClose
|
||||
FClosing : boolean; // Set to True in the CloseQuery event.
|
||||
|
||||
FPendingMsgID : integer;
|
||||
|
||||
// You have to handle this two messages to call NotifyMoveOrResizeStarted or some page elements will be misaligned.
|
||||
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
|
||||
procedure WMMoving(var aMessage : TMessage); message WM_MOVING;
|
||||
@@ -171,8 +173,9 @@ end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FCanClose := False;
|
||||
FClosing := False;
|
||||
FCanClose := False;
|
||||
FClosing := False;
|
||||
FPendingMsgID := 0;
|
||||
Chromium1.DefaultURL := AddressEdt.Text;
|
||||
end;
|
||||
|
||||
@@ -189,7 +192,8 @@ end;
|
||||
|
||||
procedure TForm1.CanEmulateBtnClick(Sender: TObject);
|
||||
begin
|
||||
Chromium1.ExecuteDevToolsMethod(DEVTOOLS_CANEMULATE_MSGID, 'Emulation.canEmulate', nil);
|
||||
FPendingMsgID := DEVTOOLS_CANEMULATE_MSGID;
|
||||
Chromium1.ExecuteDevToolsMethod(0, 'Emulation.canEmulate', nil);
|
||||
end;
|
||||
|
||||
procedure TForm1.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
@@ -228,7 +232,7 @@ procedure TForm1.Chromium1DevToolsMethodResult(Sender: TObject;
|
||||
const browser: ICefBrowser; message_id: Integer; success: Boolean;
|
||||
const result: ICefValue);
|
||||
begin
|
||||
case message_id of
|
||||
case FPendingMsgID of
|
||||
DEVTOOLS_SETUSERAGENTOVERRIDE_MSGID : HandleSetUserAgentResult(success, result);
|
||||
DEVTOOLS_SETTOUCHEMULATIONENABLED_MSGID : HandleSetTouchEmulationEnabledResult(success, result);
|
||||
DEVTOOLS_CANEMULATE_MSGID : HandleCanEmulateResult(success, result);
|
||||
@@ -248,7 +252,8 @@ end;
|
||||
|
||||
procedure TForm1.ClearDeviceMetricsOverrideBtnClick(Sender: TObject);
|
||||
begin
|
||||
Chromium1.ExecuteDevToolsMethod(DEVTOOLS_CLEARDEVICEMETRICSOVERRIDE_MSGID, 'Emulation.clearDeviceMetricsOverride', nil);
|
||||
FPendingMsgID := DEVTOOLS_CLEARDEVICEMETRICSOVERRIDE_MSGID;
|
||||
Chromium1.ExecuteDevToolsMethod(0, 'Emulation.clearDeviceMetricsOverride', nil);
|
||||
end;
|
||||
|
||||
procedure TForm1.EmulateTouchChkClick(Sender: TObject);
|
||||
@@ -262,7 +267,8 @@ begin
|
||||
if EmulateTouchChk.Checked then
|
||||
TempParams.SetInt('maxTouchPoints', 2);
|
||||
|
||||
Chromium1.ExecuteDevToolsMethod(DEVTOOLS_SETTOUCHEMULATIONENABLED_MSGID, 'Emulation.setTouchEmulationEnabled', TempParams);
|
||||
FPendingMsgID := DEVTOOLS_SETTOUCHEMULATIONENABLED_MSGID;
|
||||
Chromium1.ExecuteDevToolsMethod(0, 'Emulation.setTouchEmulationEnabled', TempParams);
|
||||
finally
|
||||
TempParams := nil;
|
||||
end;
|
||||
@@ -314,7 +320,8 @@ begin
|
||||
TempDict.SetInt('angle', AngleEdt.Value);
|
||||
TempParams.SetDictionary('screenOrientation', TempDict);
|
||||
|
||||
Chromium1.ExecuteDevToolsMethod(DEVTOOLS_SETDEVICEMETRICSOVERRIDE_MSGID, 'Emulation.setDeviceMetricsOverride', TempParams);
|
||||
FPendingMsgID := DEVTOOLS_SETDEVICEMETRICSOVERRIDE_MSGID;
|
||||
Chromium1.ExecuteDevToolsMethod(0, 'Emulation.setDeviceMetricsOverride', TempParams);
|
||||
finally
|
||||
TempDict := nil;
|
||||
TempParams := nil;
|
||||
@@ -329,7 +336,8 @@ begin
|
||||
TempParams := TCefDictionaryValueRef.New;
|
||||
TempParams.SetString('userAgent', UserAgentCb.Text);
|
||||
|
||||
Chromium1.ExecuteDevToolsMethod(DEVTOOLS_SETUSERAGENTOVERRIDE_MSGID, 'Emulation.setUserAgentOverride', TempParams);
|
||||
FPendingMsgID := DEVTOOLS_SETUSERAGENTOVERRIDE_MSGID;
|
||||
Chromium1.ExecuteDevToolsMethod(0, 'Emulation.setUserAgentOverride', TempParams);
|
||||
finally
|
||||
TempParams := nil;
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user