Fixed incorrect coordinates using the wheel button in OSR demos for Windows (VCL).

This commit is contained in:
Salvador Diaz Fau 2021-01-29 18:27:10 +01:00
parent e3fdfe8a45
commit cd46aa097d
11 changed files with 126 additions and 56 deletions

View File

@ -192,6 +192,7 @@ procedure TForm1.AppEventsMessage(var Msg: tagMSG; var Handled: Boolean);
var
TempKeyEvent : TCefKeyEvent;
TempMouseEvent : TCefMouseEvent;
TempPoint : TPoint;
begin
case Msg.message of
WM_SYSCHAR :
@ -302,11 +303,18 @@ begin
WM_MOUSEWHEEL :
if Panel1.Focused then
begin
TempMouseEvent.x := Msg.lParam and $FFFF;
TempMouseEvent.y := Msg.lParam shr 16;
GetCursorPos(TempPoint);
TempPoint := Panel1.ScreenToclient(TempPoint);
TempMouseEvent.x := TempPoint.x;
TempMouseEvent.y := TempPoint.y;
TempMouseEvent.modifiers := GetCefMouseModifiers(Msg.wParam);
DeviceToLogical(TempMouseEvent, Panel1.ScreenScale);
chrmosr.SendMouseWheelEvent(@TempMouseEvent, 0, int16(Msg.wParam shr 16));
if CefIsKeyDown(VK_SHIFT) then
chrmosr.SendMouseWheelEvent(@TempMouseEvent, smallint(Msg.wParam shr 16), 0)
else
chrmosr.SendMouseWheelEvent(@TempMouseEvent, 0, smallint(Msg.wParam shr 16));
end;
end;
end;

View File

@ -196,6 +196,7 @@ procedure TOSRExternalPumpBrowserFrm.AppEventsMessage(var Msg: tagMSG; var Handl
var
TempKeyEvent : TCefKeyEvent;
TempMouseEvent : TCefMouseEvent;
TempPoint : TPoint;
begin
case Msg.message of
WM_SYSCHAR :
@ -299,11 +300,18 @@ begin
WM_MOUSEWHEEL :
if Panel1.Focused then
begin
TempMouseEvent.x := Msg.lParam and $FFFF;
TempMouseEvent.y := Msg.lParam shr 16;
GetCursorPos(TempPoint);
TempPoint := Panel1.ScreenToclient(TempPoint);
TempMouseEvent.x := TempPoint.x;
TempMouseEvent.y := TempPoint.y;
TempMouseEvent.modifiers := GetCefMouseModifiers(Msg.wParam);
DeviceToLogical(TempMouseEvent, Panel1.ScreenScale);
chrmosr.SendMouseWheelEvent(@TempMouseEvent, 0, int16(Msg.wParam shr 16));
if CefIsKeyDown(VK_SHIFT) then
chrmosr.SendMouseWheelEvent(@TempMouseEvent, smallint(Msg.wParam shr 16), 0)
else
chrmosr.SendMouseWheelEvent(@TempMouseEvent, 0, smallint(Msg.wParam shr 16));
end;
end;
end;

View File

@ -293,14 +293,23 @@ end;
procedure TChildForm.HandleMouseWheelMsg(var Msg: tagMSG; var Handled: Boolean);
var
TempMouseEvent : TCefMouseEvent;
TempPoint : TPoint;
begin
if Panel1.Focused and (GlobalCEFApp <> nil) then
begin
TempMouseEvent.x := Msg.lParam and $FFFF;
TempMouseEvent.y := Msg.lParam shr 16;
GetCursorPos(TempPoint);
TempPoint := Panel1.ScreenToclient(TempPoint);
TempMouseEvent.x := TempPoint.x;
TempMouseEvent.y := TempPoint.y;
TempMouseEvent.modifiers := GetCefMouseModifiers(Msg.wParam);
DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor);
Chromium1.SendMouseWheelEvent(@TempMouseEvent, 0, int16(Msg.wParam shr 16));
DeviceToLogical(TempMouseEvent, Panel1.ScreenScale);
if CefIsKeyDown(VK_SHIFT) then
Chromium1.SendMouseWheelEvent(@TempMouseEvent, smallint(Msg.wParam shr 16), 0)
else
Chromium1.SendMouseWheelEvent(@TempMouseEvent, 0, smallint(Msg.wParam shr 16));
Handled := False;
end;
end;

View File

@ -263,6 +263,7 @@ procedure TForm1.AppEventsMessage(var Msg: tagMSG; var Handled: Boolean);
var
TempKeyEvent : TCefKeyEvent;
TempMouseEvent : TCefMouseEvent;
TempPoint : TPoint;
begin
case Msg.message of
WM_SYSCHAR :
@ -366,10 +367,17 @@ begin
WM_MOUSEWHEEL :
if Panel1.Focused then
begin
TempMouseEvent.x := Msg.lParam and $FFFF;
TempMouseEvent.y := Msg.lParam shr 16;
GetCursorPos(TempPoint);
TempPoint := Panel1.ScreenToclient(TempPoint);
TempMouseEvent.x := TempPoint.x;
TempMouseEvent.y := TempPoint.y;
TempMouseEvent.modifiers := GetCefMouseModifiers(Msg.wParam);
DeviceToLogical(TempMouseEvent, Panel1.ScreenScale);
if CefIsKeyDown(VK_SHIFT) then
chrmosr.SendMouseWheelEvent(@TempMouseEvent, smallint(Msg.wParam shr 16), 0)
else
chrmosr.SendMouseWheelEvent(@TempMouseEvent, 0, smallint(Msg.wParam shr 16));
end;
end;

View File

@ -22,8 +22,8 @@
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="325"/>
<CursorPos X="25" Y="334"/>
<TopLine Value="989"/>
<CursorPos Y="999"/>
<UsageCount Value="27"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@ -88,123 +88,123 @@
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="845" Column="52" TopLine="804"/>
<Caret Line="1009" Column="52" TopLine="968"/>
</Position1>
<Position2>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="859" Column="52" TopLine="818"/>
<Caret Line="257" Column="51" TopLine="217"/>
</Position2>
<Position3>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="1009" Column="52" TopLine="968"/>
<Caret Line="354" Column="21" TopLine="317"/>
</Position3>
<Position4>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="257" Column="51" TopLine="217"/>
<Caret Line="364" Column="56" TopLine="337"/>
</Position4>
<Position5>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="354" Column="21" TopLine="317"/>
<Caret Line="365" Column="37" TopLine="337"/>
</Position5>
<Position6>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="364" Column="56" TopLine="337"/>
<Caret Line="384" Column="58" TopLine="343"/>
</Position6>
<Position7>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="365" Column="37" TopLine="337"/>
<Caret Line="531" Column="54" TopLine="502"/>
</Position7>
<Position8>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="384" Column="58" TopLine="343"/>
<Caret Line="794" Column="91" TopLine="754"/>
</Position8>
<Position9>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="531" Column="54" TopLine="502"/>
<Caret Line="812" Column="50" TopLine="772"/>
</Position9>
<Position10>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="794" Column="91" TopLine="754"/>
<Caret Line="826" Column="52" TopLine="786"/>
</Position10>
<Position11>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="812" Column="50" TopLine="772"/>
<Caret Line="837" Column="87" TopLine="818"/>
</Position11>
<Position12>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="826" Column="52" TopLine="786"/>
<Caret Line="984" Column="59" TopLine="944"/>
</Position12>
<Position13>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="837" Column="87" TopLine="818"/>
<Caret Line="252" Column="40" TopLine="229"/>
</Position13>
<Position14>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="984" Column="59" TopLine="944"/>
<Caret Line="342" Column="40" TopLine="319"/>
</Position14>
<Position15>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="252" Column="40" TopLine="229"/>
<Caret Line="365" Column="37" TopLine="354"/>
</Position15>
<Position16>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="342" Column="40" TopLine="319"/>
<Caret Line="380" Column="36" TopLine="354"/>
</Position16>
<Position17>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="365" Column="37" TopLine="354"/>
<Caret Line="526" Column="44" TopLine="497"/>
</Position17>
<Position18>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="380" Column="36" TopLine="354"/>
<Caret Line="793" Column="48" TopLine="767"/>
</Position18>
<Position19>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="526" Column="44" TopLine="497"/>
<Caret Line="811" Column="48" TopLine="770"/>
</Position19>
<Position20>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="793" Column="48" TopLine="767"/>
<Caret Line="825" Column="48" TopLine="784"/>
</Position20>
<Position21>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="811" Column="48" TopLine="770"/>
<Caret Line="836" Column="48" TopLine="795"/>
</Position21>
<Position22>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="825" Column="48" TopLine="784"/>
<Caret Line="246" Column="61" TopLine="231"/>
</Position22>
<Position23>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="836" Column="48" TopLine="795"/>
<Caret Line="94" Column="15" TopLine="94"/>
</Position23>
<Position24>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="246" Column="61" TopLine="231"/>
<Caret Line="146" Column="21" TopLine="134"/>
</Position24>
<Position25>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="94" Column="15" TopLine="94"/>
<Caret Line="662" Column="74" TopLine="655"/>
</Position25>
<Position26>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="146" Column="21" TopLine="134"/>
<Caret Line="146" Column="15" TopLine="133"/>
</Position26>
<Position27>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="662" Column="74" TopLine="655"/>
<Caret Line="653" Column="3" TopLine="647"/>
</Position27>
<Position28>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="146" Column="15" TopLine="133"/>
<Caret Line="95" Column="168" TopLine="88"/>
</Position28>
<Position29>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="653" Column="3" TopLine="647"/>
<Caret Line="345" Column="70" TopLine="324"/>
</Position29>
<Position30>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="95" Column="168" TopLine="88"/>
<Caret Line="82" Column="15" TopLine="71"/>
</Position30>
</JumpHistory>
<RunParams>

View File

@ -996,6 +996,10 @@ begin
TempEvent.y := MousePos.y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, Panel1.ScreenScale);
if CefIsKeyDown(VK_SHIFT) then
chrmosr.SendMouseWheelEvent(@TempEvent, WheelDelta, 0)
else
chrmosr.SendMouseWheelEvent(@TempEvent, 0, WheelDelta);
end;

View File

@ -21,7 +21,6 @@
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<TopLine Value="122"/>
<CursorPos X="105" Y="139"/>
<UsageCount Value="22"/>
@ -35,9 +34,10 @@
<ComponentName Value="ChildForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="287"/>
<CursorPos X="25" Y="296"/>
<TopLine Value="944"/>
<CursorPos Y="960"/>
<UsageCount Value="22"/>
<Bookmarks Count="2">
<Item0 X="64" Y="174" ID="2"/>
@ -77,7 +77,7 @@
<UsageCount Value="10"/>
</Unit6>
</Units>
<JumpHistory Count="24" HistoryIndex="23">
<JumpHistory Count="26" HistoryIndex="25">
<Position1>
<Filename Value="uMainForm.pas"/>
<Caret Line="81" Column="34" TopLine="68"/>
@ -174,6 +174,14 @@
<Filename Value="uChildForm.pas"/>
<Caret Line="88" Column="168" TopLine="78"/>
</Position24>
<Position25>
<Filename Value="uChildForm.pas"/>
<Caret Line="296" Column="25" TopLine="287"/>
</Position25>
<Position26>
<Filename Value="uChildForm.pas"/>
<Caret Line="74" Column="22" TopLine="59"/>
</Position26>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>

View File

@ -952,6 +952,10 @@ begin
TempEvent.y := MousePos.y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
if CefIsKeyDown(VK_SHIFT) then
chrmosr.SendMouseWheelEvent(@TempEvent, WheelDelta, 0)
else
chrmosr.SendMouseWheelEvent(@TempEvent, 0, WheelDelta);
end;
end;

View File

@ -38,8 +38,8 @@
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="752"/>
<CursorPos X="72" Y="824"/>
<TopLine Value="998"/>
<CursorPos X="87" Y="1011"/>
<UsageCount Value="42"/>
<Bookmarks Count="2">
<Item0 X="40" Y="302" ID="4"/>
@ -251,7 +251,24 @@
<UsageCount Value="10"/>
</Unit29>
</Units>
<JumpHistory HistoryIndex="-1"/>
<JumpHistory Count="4" HistoryIndex="3">
<Position1>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="768" Column="52" TopLine="752"/>
</Position1>
<Position2>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="80" Column="15" TopLine="74"/>
</Position2>
<Position3>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="963" Column="3" TopLine="958"/>
</Position3>
<Position4>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="79" Column="15" TopLine="67"/>
</Position4>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0" ActiveMode="default"/>

View File

@ -1005,6 +1005,10 @@ begin
TempEvent.y := MousePos.y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, Panel1.ScreenScale);
if CefIsKeyDown(VK_SHIFT) then
chrmosr.SendMouseWheelEvent(@TempEvent, WheelDelta, 0)
else
chrmosr.SendMouseWheelEvent(@TempEvent, 0, WheelDelta);
end;

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 244,
"InternalVersion" : 245,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "88.1.6.0"
}