SendTouchEvent
Posted: Thu Jul 18, 2024 6:22 pm
procedure TForm1.SendTouchEvent(eventType: string; x, y: Integer);
var
TempParams: ICefDictionaryValue;
TouchPoints: ICefListValue;
TouchPoint: ICefDictionaryValue;
begin
TempParams := TCefDictionaryValueRef.New;
TouchPoints := TCefListValueRef.New;
TouchPoint := TCefDictionaryValueRef.New;
TouchPoint.SetInt('x', x);
TouchPoint.SetInt('y', y);
TouchPoint.SetInt('radiusX', 10); // Sets the radius of the touch point.
TouchPoint.SetInt('radiusY', 10);
TouchPoint.SetDouble('force', 1); // Set the touch pressure.
TouchPoint.SetInt('rotationAngle', 0);
TouchPoints.SetDictionary(0, TouchPoint);
TempParams.SetList('touchPoints', TouchPoints);
TempParams.SetString('type', eventType);
Chromium1.ExecuteDevToolsMethod(0, 'Input.dispatchTouchEvent', TempParams);
end;
procedure TForm1.Chromium1RenderCompMsg(Sender: TObject;
var aMessage: TMessage; var aHandled: Boolean);
var X, Y: Integer;
begin
if FClosing then
Exit;
case aMessage.Msg of
WM_LBUTTONDOWN:
begin
X := LOWORD(aMessage.LParam);
Y := HIWORD(aMessage.LParam);
DispatchTouchEvent(Chromium1, 'touchStart', X, Y);
FTouchActive := True;
aHandled := True;
end;
WM_MOUSEMOVE:
begin
if FTouchActive then
begin
X := LOWORD(aMessage.LParam);
Y := HIWORD(aMessage.LParam);
DispatchTouchEvent(Chromium1, 'touchMove', X, Y);
aHandled := True;
end;
end;
WM_LBUTTONUP:
begin
if FTouchActive then
begin
X := LOWORD(aMessage.LParam);
Y := HIWORD(aMessage.LParam);
DispatchTouchEvent(Chromium1, 'touchEnd', X, Y);
FTouchActive := False;
aHandled := True;
end;
end;
end;
end;
FTouchActive : Boolean;
Mobile agent required
I really need it.
Please add it to the mobile demo section.
In the case of buttons, you can move them by sliding.
For buttons, you can slide them to move them.
///////////////
document.addEventListener('touchstart', function(event) {
console.log('touchstart', event);
});
document.addEventListener('touchmove', function(event) {
console.log('touchmove', event);
});
document.addEventListener('touchend', function(event) {
console.log('touchend', event);
});
///////////////
var
TempParams: ICefDictionaryValue;
TouchPoints: ICefListValue;
TouchPoint: ICefDictionaryValue;
begin
TempParams := TCefDictionaryValueRef.New;
TouchPoints := TCefListValueRef.New;
TouchPoint := TCefDictionaryValueRef.New;
TouchPoint.SetInt('x', x);
TouchPoint.SetInt('y', y);
TouchPoint.SetInt('radiusX', 10); // Sets the radius of the touch point.
TouchPoint.SetInt('radiusY', 10);
TouchPoint.SetDouble('force', 1); // Set the touch pressure.
TouchPoint.SetInt('rotationAngle', 0);
TouchPoints.SetDictionary(0, TouchPoint);
TempParams.SetList('touchPoints', TouchPoints);
TempParams.SetString('type', eventType);
Chromium1.ExecuteDevToolsMethod(0, 'Input.dispatchTouchEvent', TempParams);
end;
procedure TForm1.Chromium1RenderCompMsg(Sender: TObject;
var aMessage: TMessage; var aHandled: Boolean);
var X, Y: Integer;
begin
if FClosing then
Exit;
case aMessage.Msg of
WM_LBUTTONDOWN:
begin
X := LOWORD(aMessage.LParam);
Y := HIWORD(aMessage.LParam);
DispatchTouchEvent(Chromium1, 'touchStart', X, Y);
FTouchActive := True;
aHandled := True;
end;
WM_MOUSEMOVE:
begin
if FTouchActive then
begin
X := LOWORD(aMessage.LParam);
Y := HIWORD(aMessage.LParam);
DispatchTouchEvent(Chromium1, 'touchMove', X, Y);
aHandled := True;
end;
end;
WM_LBUTTONUP:
begin
if FTouchActive then
begin
X := LOWORD(aMessage.LParam);
Y := HIWORD(aMessage.LParam);
DispatchTouchEvent(Chromium1, 'touchEnd', X, Y);
FTouchActive := False;
aHandled := True;
end;
end;
end;
end;
FTouchActive : Boolean;
Mobile agent required
I really need it.
Please add it to the mobile demo section.
In the case of buttons, you can move them by sliding.
For buttons, you can slide them to move them.


///////////////
document.addEventListener('touchstart', function(event) {
console.log('touchstart', event);
});
document.addEventListener('touchmove', function(event) {
console.log('touchmove', event);
});
document.addEventListener('touchend', function(event) {
console.log('touchend', event);
});
///////////////