mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-16 00:05:55 +01:00
Bug fix #92
This commit is contained in:
parent
261c6c9ba5
commit
3f94588897
@ -97,20 +97,13 @@ type
|
|||||||
procedure chrmosrAfterCreated(Sender: TObject; const browser: ICefBrowser);
|
procedure chrmosrAfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||||
procedure chrmosrClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean);
|
procedure chrmosrClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean);
|
||||||
procedure chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
|
procedure chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||||
|
procedure chrmosrTooltip(Sender: TObject; const browser: ICefBrowser; var text: ustring; out Result: Boolean);
|
||||||
|
procedure chrmosrBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean; out Result: Boolean);
|
||||||
|
|
||||||
procedure Timer1Timer(Sender: TObject);
|
procedure Timer1Timer(Sender: TObject);
|
||||||
procedure AddressEdtEnter(Sender: TObject);
|
procedure AddressEdtEnter(Sender: TObject);
|
||||||
procedure SnapshotBtnClick(Sender: TObject);
|
procedure SnapshotBtnClick(Sender: TObject);
|
||||||
procedure SnapshotBtnEnter(Sender: TObject);
|
procedure SnapshotBtnEnter(Sender: TObject);
|
||||||
procedure chrmosrTooltip(Sender: TObject; const browser: ICefBrowser;
|
|
||||||
var text: ustring; out Result: Boolean);
|
|
||||||
procedure chrmosrBeforePopup(Sender: TObject;
|
|
||||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
|
|
||||||
targetFrameName: ustring;
|
|
||||||
targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean;
|
|
||||||
var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo;
|
|
||||||
var client: ICefClient; var settings: TCefBrowserSettings;
|
|
||||||
var noJavascriptAccess: Boolean; out Result: Boolean);
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
FPopUpBitmap : TBitmap;
|
FPopUpBitmap : TBitmap;
|
||||||
@ -125,10 +118,17 @@ type
|
|||||||
FMouseWheelService : IFMXMouseService;
|
FMouseWheelService : IFMXMouseService;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
FLastClickCount : integer;
|
||||||
|
FLastClickTime : integer;
|
||||||
|
FLastClickPoint : TPointF;
|
||||||
|
FLastClickButton : TMouseButton;
|
||||||
|
|
||||||
procedure LoadURL;
|
procedure LoadURL;
|
||||||
function getModifiers(Shift: TShiftState): TCefEventFlags;
|
function getModifiers(Shift: TShiftState): TCefEventFlags;
|
||||||
function GetButton(Button: TMouseButton): TCefMouseButtonType;
|
function GetButton(Button: TMouseButton): TCefMouseButtonType;
|
||||||
function SendCompMessage(aMsg : cardinal; wParam : cardinal = 0; lParam : integer = 0) : boolean;
|
function SendCompMessage(aMsg : cardinal; wParam : cardinal = 0; lParam : integer = 0) : boolean;
|
||||||
|
procedure InitializeLastClick;
|
||||||
|
function CancelPreviousClick(const x, y : single; var aCurrentTime : integer) : boolean;
|
||||||
|
|
||||||
public
|
public
|
||||||
procedure DoResize;
|
procedure DoResize;
|
||||||
@ -207,6 +207,8 @@ begin
|
|||||||
FClosing := False;
|
FClosing := False;
|
||||||
FResizeCS := TCriticalSection.Create;
|
FResizeCS := TCriticalSection.Create;
|
||||||
|
|
||||||
|
InitializeLastClick;
|
||||||
|
|
||||||
{$IFDEF DELPHI17_UP}
|
{$IFDEF DELPHI17_UP}
|
||||||
if TPlatformServices.Current.SupportsPlatformService(IFMXMouseService) then
|
if TPlatformServices.Current.SupportsPlatformService(IFMXMouseService) then
|
||||||
FMouseWheelService := TPlatformServices.Current.GetPlatformService(IFMXMouseService) as IFMXMouseService;
|
FMouseWheelService := TPlatformServices.Current.GetPlatformService(IFMXMouseService) as IFMXMouseService;
|
||||||
@ -343,15 +345,28 @@ procedure TFMXExternalPumpBrowserFrm.Panel1MouseDown(Sender : TObject;
|
|||||||
X, Y : Single);
|
X, Y : Single);
|
||||||
var
|
var
|
||||||
TempEvent : TCefMouseEvent;
|
TempEvent : TCefMouseEvent;
|
||||||
|
TempTime : integer;
|
||||||
begin
|
begin
|
||||||
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
if (GlobalCEFApp <> nil) and (chrmosr <> nil) and not(ssShift in Shift) then
|
||||||
begin
|
begin
|
||||||
Panel1.SetFocus;
|
Panel1.SetFocus;
|
||||||
|
|
||||||
|
if not(CancelPreviousClick(x, y, TempTime)) and (Button = FLastClickButton) then
|
||||||
|
inc(FLastClickCount)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FLastClickPoint.x := x;
|
||||||
|
FLastClickPoint.y := y;
|
||||||
|
FLastClickCount := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
FLastClickTime := TempTime;
|
||||||
|
FLastClickButton := Button;
|
||||||
|
|
||||||
TempEvent.x := round(X);
|
TempEvent.x := round(X);
|
||||||
TempEvent.y := round(Y);
|
TempEvent.y := round(Y);
|
||||||
TempEvent.modifiers := getModifiers(Shift);
|
TempEvent.modifiers := getModifiers(Shift);
|
||||||
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), False, 1);
|
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), False, FLastClickCount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -359,11 +374,15 @@ procedure TFMXExternalPumpBrowserFrm.Panel1MouseLeave(Sender: TObject);
|
|||||||
var
|
var
|
||||||
TempEvent : TCefMouseEvent;
|
TempEvent : TCefMouseEvent;
|
||||||
TempPoint : TPoint;
|
TempPoint : TPoint;
|
||||||
|
TempTime : integer;
|
||||||
begin
|
begin
|
||||||
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
||||||
begin
|
begin
|
||||||
GetCursorPos(TempPoint);
|
GetCursorPos(TempPoint);
|
||||||
TempPoint := Panel1.ScreenToclient(TempPoint);
|
TempPoint := Panel1.ScreenToclient(TempPoint);
|
||||||
|
|
||||||
|
if CancelPreviousClick(TempPoint.x, TempPoint.y, TempTime) then InitializeLastClick;
|
||||||
|
|
||||||
TempEvent.x := TempPoint.x;
|
TempEvent.x := TempPoint.x;
|
||||||
TempEvent.y := TempPoint.y;
|
TempEvent.y := TempPoint.y;
|
||||||
TempEvent.modifiers := GetCefMouseModifiers;
|
TempEvent.modifiers := GetCefMouseModifiers;
|
||||||
@ -376,9 +395,12 @@ procedure TFMXExternalPumpBrowserFrm.Panel1MouseMove(Sender : TObject;
|
|||||||
X, Y : Single);
|
X, Y : Single);
|
||||||
var
|
var
|
||||||
TempEvent : TCefMouseEvent;
|
TempEvent : TCefMouseEvent;
|
||||||
|
TempTime : integer;
|
||||||
begin
|
begin
|
||||||
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
||||||
begin
|
begin
|
||||||
|
if CancelPreviousClick(x, y, TempTime) then InitializeLastClick;
|
||||||
|
|
||||||
TempEvent.x := round(X);
|
TempEvent.x := round(X);
|
||||||
TempEvent.y := round(Y);
|
TempEvent.y := round(Y);
|
||||||
TempEvent.modifiers := getModifiers(Shift);
|
TempEvent.modifiers := getModifiers(Shift);
|
||||||
@ -398,7 +420,7 @@ begin
|
|||||||
TempEvent.x := round(X);
|
TempEvent.x := round(X);
|
||||||
TempEvent.y := round(Y);
|
TempEvent.y := round(Y);
|
||||||
TempEvent.modifiers := getModifiers(Shift);
|
TempEvent.modifiers := getModifiers(Shift);
|
||||||
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), True, 1);
|
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), True, FLastClickCount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -860,6 +882,29 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFMXExternalPumpBrowserFrm.InitializeLastClick;
|
||||||
|
begin
|
||||||
|
FLastClickCount := 0;
|
||||||
|
FLastClickTime := 0;
|
||||||
|
FLastClickPoint.x := 0;
|
||||||
|
FLastClickPoint.y := 0;
|
||||||
|
FLastClickButton := TMouseButton.mbLeft;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TFMXExternalPumpBrowserFrm.CancelPreviousClick(const x, y : single; var aCurrentTime : integer) : boolean;
|
||||||
|
begin
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
|
aCurrentTime := GetMessageTime;
|
||||||
|
|
||||||
|
Result := (abs(FLastClickPoint.x - x) > (GetSystemMetrics(SM_CXDOUBLECLK) div 2)) or
|
||||||
|
(abs(FLastClickPoint.y - y) > (GetSystemMetrics(SM_CYDOUBLECLK) div 2)) or
|
||||||
|
(cardinal(aCurrentTime - FLastClickTime) > GetDoubleClickTime);
|
||||||
|
{$ELSE}
|
||||||
|
aCurrentTime := 0;
|
||||||
|
Result := False;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TFMXExternalPumpBrowserFrm.SnapshotBtnClick(Sender: TObject);
|
procedure TFMXExternalPumpBrowserFrm.SnapshotBtnClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if SaveDialog1.Execute then Panel1.SaveToFile(SaveDialog1.FileName);
|
if SaveDialog1.Execute then Panel1.SaveToFile(SaveDialog1.FileName);
|
||||||
|
@ -122,6 +122,7 @@ object OSRExternalPumpBrowserFrm: TOSRExternalPumpBrowserFrm
|
|||||||
OnMouseLeave = Panel1MouseLeave
|
OnMouseLeave = Panel1MouseLeave
|
||||||
end
|
end
|
||||||
object chrmosr: TChromium
|
object chrmosr: TChromium
|
||||||
|
OnTooltip = chrmosrTooltip
|
||||||
OnBeforePopup = chrmosrBeforePopup
|
OnBeforePopup = chrmosrBeforePopup
|
||||||
OnAfterCreated = chrmosrAfterCreated
|
OnAfterCreated = chrmosrAfterCreated
|
||||||
OnBeforeClose = chrmosrBeforeClose
|
OnBeforeClose = chrmosrBeforeClose
|
||||||
|
@ -96,19 +96,14 @@ type
|
|||||||
procedure chrmosrAfterCreated(Sender: TObject; const browser: ICefBrowser);
|
procedure chrmosrAfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||||
procedure chrmosrClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean);
|
procedure chrmosrClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean);
|
||||||
procedure chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
|
procedure chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||||
|
procedure chrmosrTooltip(Sender: TObject; const browser: ICefBrowser; var text: ustring; out Result: Boolean);
|
||||||
|
procedure chrmosrBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean; out Result: Boolean);
|
||||||
|
|
||||||
procedure SnapshotBtnClick(Sender: TObject);
|
procedure SnapshotBtnClick(Sender: TObject);
|
||||||
procedure SnapshotBtnEnter(Sender: TObject);
|
procedure SnapshotBtnEnter(Sender: TObject);
|
||||||
|
|
||||||
procedure Timer1Timer(Sender: TObject);
|
procedure Timer1Timer(Sender: TObject);
|
||||||
procedure ComboBox1Enter(Sender: TObject);
|
procedure ComboBox1Enter(Sender: TObject);
|
||||||
procedure chrmosrBeforePopup(Sender: TObject;
|
|
||||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
|
|
||||||
targetFrameName: ustring;
|
|
||||||
targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean;
|
|
||||||
var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo;
|
|
||||||
var client: ICefClient; var settings: TCefBrowserSettings;
|
|
||||||
var noJavascriptAccess: Boolean; out Result: Boolean);
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
FPopUpBitmap : TBitmap;
|
FPopUpBitmap : TBitmap;
|
||||||
@ -120,9 +115,16 @@ type
|
|||||||
FClosing : boolean;
|
FClosing : boolean;
|
||||||
FResizeCS : TCriticalSection;
|
FResizeCS : TCriticalSection;
|
||||||
|
|
||||||
|
FLastClickCount : integer;
|
||||||
|
FLastClickTime : integer;
|
||||||
|
FLastClickPoint : TPoint;
|
||||||
|
FLastClickButton : TMouseButton;
|
||||||
|
|
||||||
function getModifiers(Shift: TShiftState): TCefEventFlags;
|
function getModifiers(Shift: TShiftState): TCefEventFlags;
|
||||||
function GetButton(Button: TMouseButton): TCefMouseButtonType;
|
function GetButton(Button: TMouseButton): TCefMouseButtonType;
|
||||||
procedure DoResize;
|
procedure DoResize;
|
||||||
|
procedure InitializeLastClick;
|
||||||
|
function CancelPreviousClick(x, y : integer; var aCurrentTime : integer) : boolean;
|
||||||
|
|
||||||
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
|
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
|
||||||
procedure WMMoving(var aMessage : TMessage); message WM_MOVING;
|
procedure WMMoving(var aMessage : TMessage); message WM_MOVING;
|
||||||
@ -542,6 +544,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TOSRExternalPumpBrowserFrm.chrmosrTooltip(Sender: TObject; const browser: ICefBrowser; var text: ustring; out Result: Boolean);
|
||||||
|
begin
|
||||||
|
Panel1.hint := text;
|
||||||
|
Panel1.ShowHint := (length(text) > 0);
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TOSRExternalPumpBrowserFrm.ComboBox1Enter(Sender: TObject);
|
procedure TOSRExternalPumpBrowserFrm.ComboBox1Enter(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
chrmosr.SendFocusEvent(False);
|
chrmosr.SendFocusEvent(False);
|
||||||
@ -635,6 +644,8 @@ begin
|
|||||||
FCanClose := False;
|
FCanClose := False;
|
||||||
FClosing := False;
|
FClosing := False;
|
||||||
FResizeCS := TCriticalSection.Create;
|
FResizeCS := TCriticalSection.Create;
|
||||||
|
|
||||||
|
InitializeLastClick;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TOSRExternalPumpBrowserFrm.FormDestroy(Sender: TObject);
|
procedure TOSRExternalPumpBrowserFrm.FormDestroy(Sender: TObject);
|
||||||
@ -677,16 +688,29 @@ end;
|
|||||||
procedure TOSRExternalPumpBrowserFrm.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TOSRExternalPumpBrowserFrm.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
var
|
var
|
||||||
TempEvent : TCefMouseEvent;
|
TempEvent : TCefMouseEvent;
|
||||||
|
TempTime : integer;
|
||||||
begin
|
begin
|
||||||
if (GlobalCEFApp <> nil) then
|
if (GlobalCEFApp <> nil) and (chrmosr <> nil) and not(ssShift in Shift) then
|
||||||
begin
|
begin
|
||||||
Panel1.SetFocus;
|
Panel1.SetFocus;
|
||||||
|
|
||||||
|
if not(CancelPreviousClick(x, y, TempTime)) and (Button = FLastClickButton) then
|
||||||
|
inc(FLastClickCount)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FLastClickPoint.x := x;
|
||||||
|
FLastClickPoint.y := y;
|
||||||
|
FLastClickCount := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
FLastClickTime := TempTime;
|
||||||
|
FLastClickButton := Button;
|
||||||
|
|
||||||
TempEvent.x := X;
|
TempEvent.x := X;
|
||||||
TempEvent.y := Y;
|
TempEvent.y := Y;
|
||||||
TempEvent.modifiers := getModifiers(Shift);
|
TempEvent.modifiers := getModifiers(Shift);
|
||||||
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
|
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
|
||||||
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), False, 1);
|
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), False, FLastClickCount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -694,11 +718,15 @@ procedure TOSRExternalPumpBrowserFrm.Panel1MouseLeave(Sender: TObject);
|
|||||||
var
|
var
|
||||||
TempEvent : TCefMouseEvent;
|
TempEvent : TCefMouseEvent;
|
||||||
TempPoint : TPoint;
|
TempPoint : TPoint;
|
||||||
|
TempTime : integer;
|
||||||
begin
|
begin
|
||||||
if (GlobalCEFApp <> nil) then
|
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
||||||
begin
|
begin
|
||||||
GetCursorPos(TempPoint);
|
GetCursorPos(TempPoint);
|
||||||
TempPoint := Panel1.ScreenToclient(TempPoint);
|
TempPoint := Panel1.ScreenToclient(TempPoint);
|
||||||
|
|
||||||
|
if CancelPreviousClick(TempPoint.x, TempPoint.y, TempTime) then InitializeLastClick;
|
||||||
|
|
||||||
TempEvent.x := TempPoint.x;
|
TempEvent.x := TempPoint.x;
|
||||||
TempEvent.y := TempPoint.y;
|
TempEvent.y := TempPoint.y;
|
||||||
TempEvent.modifiers := GetCefMouseModifiers;
|
TempEvent.modifiers := GetCefMouseModifiers;
|
||||||
@ -710,9 +738,12 @@ end;
|
|||||||
procedure TOSRExternalPumpBrowserFrm.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
procedure TOSRExternalPumpBrowserFrm.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
||||||
var
|
var
|
||||||
TempEvent : TCefMouseEvent;
|
TempEvent : TCefMouseEvent;
|
||||||
|
TempTime : integer;
|
||||||
begin
|
begin
|
||||||
if (GlobalCEFApp <> nil) then
|
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
||||||
begin
|
begin
|
||||||
|
if CancelPreviousClick(x, y, TempTime) then InitializeLastClick;
|
||||||
|
|
||||||
TempEvent.x := X;
|
TempEvent.x := X;
|
||||||
TempEvent.y := Y;
|
TempEvent.y := Y;
|
||||||
TempEvent.modifiers := getModifiers(Shift);
|
TempEvent.modifiers := getModifiers(Shift);
|
||||||
@ -725,13 +756,13 @@ procedure TOSRExternalPumpBrowserFrm.Panel1MouseUp(Sender: TObject; Button: TMou
|
|||||||
var
|
var
|
||||||
TempEvent : TCefMouseEvent;
|
TempEvent : TCefMouseEvent;
|
||||||
begin
|
begin
|
||||||
if (GlobalCEFApp <> nil) then
|
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
||||||
begin
|
begin
|
||||||
TempEvent.x := X;
|
TempEvent.x := X;
|
||||||
TempEvent.y := Y;
|
TempEvent.y := Y;
|
||||||
TempEvent.modifiers := getModifiers(Shift);
|
TempEvent.modifiers := getModifiers(Shift);
|
||||||
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
|
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
|
||||||
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), True, 1);
|
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), True, FLastClickCount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -765,6 +796,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TOSRExternalPumpBrowserFrm.InitializeLastClick;
|
||||||
|
begin
|
||||||
|
FLastClickCount := 0;
|
||||||
|
FLastClickTime := 0;
|
||||||
|
FLastClickPoint.x := 0;
|
||||||
|
FLastClickPoint.y := 0;
|
||||||
|
FLastClickButton := mbLeft;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TOSRExternalPumpBrowserFrm.CancelPreviousClick(x, y : integer; var aCurrentTime : integer) : boolean;
|
||||||
|
begin
|
||||||
|
aCurrentTime := GetMessageTime;
|
||||||
|
|
||||||
|
Result := (abs(FLastClickPoint.x - x) > (GetSystemMetrics(SM_CXDOUBLECLK) div 2)) or
|
||||||
|
(abs(FLastClickPoint.y - y) > (GetSystemMetrics(SM_CYDOUBLECLK) div 2)) or
|
||||||
|
(cardinal(aCurrentTime - FLastClickTime) > GetDoubleClickTime);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TOSRExternalPumpBrowserFrm.Panel1Enter(Sender: TObject);
|
procedure TOSRExternalPumpBrowserFrm.Panel1Enter(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
chrmosr.SendFocusEvent(True);
|
chrmosr.SendFocusEvent(True);
|
||||||
|
@ -114,9 +114,16 @@ type
|
|||||||
FClosing : boolean;
|
FClosing : boolean;
|
||||||
FResizeCS : TCriticalSection;
|
FResizeCS : TCriticalSection;
|
||||||
|
|
||||||
|
FLastClickCount : integer;
|
||||||
|
FLastClickTime : integer;
|
||||||
|
FLastClickPoint : TPoint;
|
||||||
|
FLastClickButton : TMouseButton;
|
||||||
|
|
||||||
function getModifiers(Shift: TShiftState): TCefEventFlags;
|
function getModifiers(Shift: TShiftState): TCefEventFlags;
|
||||||
function GetButton(Button: TMouseButton): TCefMouseButtonType;
|
function GetButton(Button: TMouseButton): TCefMouseButtonType;
|
||||||
procedure DoResize;
|
procedure DoResize;
|
||||||
|
procedure InitializeLastClick;
|
||||||
|
function CancelPreviousClick(x, y : integer; var aCurrentTime : integer) : boolean;
|
||||||
|
|
||||||
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
|
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
|
||||||
procedure WMMoving(var aMessage : TMessage); message WM_MOVING;
|
procedure WMMoving(var aMessage : TMessage); message WM_MOVING;
|
||||||
@ -645,6 +652,8 @@ begin
|
|||||||
FCanClose := False;
|
FCanClose := False;
|
||||||
FClosing := False;
|
FClosing := False;
|
||||||
FResizeCS := TCriticalSection.Create;
|
FResizeCS := TCriticalSection.Create;
|
||||||
|
|
||||||
|
InitializeLastClick;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormDestroy(Sender: TObject);
|
procedure TForm1.FormDestroy(Sender: TObject);
|
||||||
@ -687,16 +696,29 @@ end;
|
|||||||
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
var
|
var
|
||||||
TempEvent : TCefMouseEvent;
|
TempEvent : TCefMouseEvent;
|
||||||
|
TempTime : integer;
|
||||||
begin
|
begin
|
||||||
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
if (GlobalCEFApp <> nil) and (chrmosr <> nil) and not(ssShift in Shift) then
|
||||||
begin
|
begin
|
||||||
Panel1.SetFocus;
|
Panel1.SetFocus;
|
||||||
|
|
||||||
|
if not(CancelPreviousClick(x, y, TempTime)) and (Button = FLastClickButton) then
|
||||||
|
inc(FLastClickCount)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FLastClickPoint.x := x;
|
||||||
|
FLastClickPoint.y := y;
|
||||||
|
FLastClickCount := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
FLastClickTime := TempTime;
|
||||||
|
FLastClickButton := Button;
|
||||||
|
|
||||||
TempEvent.x := X;
|
TempEvent.x := X;
|
||||||
TempEvent.y := Y;
|
TempEvent.y := Y;
|
||||||
TempEvent.modifiers := getModifiers(Shift);
|
TempEvent.modifiers := getModifiers(Shift);
|
||||||
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
|
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
|
||||||
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), False, 1);
|
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), False, FLastClickCount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -704,11 +726,15 @@ procedure TForm1.Panel1MouseLeave(Sender: TObject);
|
|||||||
var
|
var
|
||||||
TempEvent : TCefMouseEvent;
|
TempEvent : TCefMouseEvent;
|
||||||
TempPoint : TPoint;
|
TempPoint : TPoint;
|
||||||
|
TempTime : integer;
|
||||||
begin
|
begin
|
||||||
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
||||||
begin
|
begin
|
||||||
GetCursorPos(TempPoint);
|
GetCursorPos(TempPoint);
|
||||||
TempPoint := Panel1.ScreenToclient(TempPoint);
|
TempPoint := Panel1.ScreenToclient(TempPoint);
|
||||||
|
|
||||||
|
if CancelPreviousClick(TempPoint.x, TempPoint.y, TempTime) then InitializeLastClick;
|
||||||
|
|
||||||
TempEvent.x := TempPoint.x;
|
TempEvent.x := TempPoint.x;
|
||||||
TempEvent.y := TempPoint.y;
|
TempEvent.y := TempPoint.y;
|
||||||
TempEvent.modifiers := GetCefMouseModifiers;
|
TempEvent.modifiers := GetCefMouseModifiers;
|
||||||
@ -720,11 +746,14 @@ end;
|
|||||||
procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
||||||
var
|
var
|
||||||
TempEvent : TCefMouseEvent;
|
TempEvent : TCefMouseEvent;
|
||||||
|
TempTime : integer;
|
||||||
begin
|
begin
|
||||||
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
if (GlobalCEFApp <> nil) and (chrmosr <> nil) then
|
||||||
begin
|
begin
|
||||||
TempEvent.x := X;
|
if CancelPreviousClick(x, y, TempTime) then InitializeLastClick;
|
||||||
TempEvent.y := Y;
|
|
||||||
|
TempEvent.x := x;
|
||||||
|
TempEvent.y := y;
|
||||||
TempEvent.modifiers := getModifiers(Shift);
|
TempEvent.modifiers := getModifiers(Shift);
|
||||||
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
|
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
|
||||||
chrmosr.SendMouseMoveEvent(@TempEvent, False);
|
chrmosr.SendMouseMoveEvent(@TempEvent, False);
|
||||||
@ -741,7 +770,7 @@ begin
|
|||||||
TempEvent.y := Y;
|
TempEvent.y := Y;
|
||||||
TempEvent.modifiers := getModifiers(Shift);
|
TempEvent.modifiers := getModifiers(Shift);
|
||||||
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
|
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
|
||||||
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), True, 1);
|
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), True, FLastClickCount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -775,6 +804,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.InitializeLastClick;
|
||||||
|
begin
|
||||||
|
FLastClickCount := 0;
|
||||||
|
FLastClickTime := 0;
|
||||||
|
FLastClickPoint.x := 0;
|
||||||
|
FLastClickPoint.y := 0;
|
||||||
|
FLastClickButton := mbLeft;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TForm1.CancelPreviousClick(x, y : integer; var aCurrentTime : integer) : boolean;
|
||||||
|
begin
|
||||||
|
aCurrentTime := GetMessageTime;
|
||||||
|
|
||||||
|
Result := (abs(FLastClickPoint.x - x) > (GetSystemMetrics(SM_CXDOUBLECLK) div 2)) or
|
||||||
|
(abs(FLastClickPoint.y - y) > (GetSystemMetrics(SM_CYDOUBLECLK) div 2)) or
|
||||||
|
(cardinal(aCurrentTime - FLastClickTime) > GetDoubleClickTime);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.Panel1Enter(Sender: TObject);
|
procedure TForm1.Panel1Enter(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
chrmosr.SendFocusEvent(True);
|
chrmosr.SendFocusEvent(True);
|
||||||
|
Loading…
Reference in New Issue
Block a user