View Issue Details

IDProjectCategoryView StatusLast Update
0035270LazarusLCLpublic2019-04-24 22:19
ReporterptvsAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformIntel Core i3-7100OSMicrosoft Windows 7 SP1 x86OS Version6.1.7601
Product Version2.1 (SVN)Product Build 
Target VersionFixed in Version 
Summary0035270: Handling mouse events through shaped TWinControl
DescriptionIf you position TGraphicControl decendant under TWinControl decendant, and then
change TWinControl's shape with SetShape so that TGraphicControl become visible,
all mouse events on the TGraphicControl would be handled by the form.

This happens in TWinControl.IsControlMouseMsg():
[code]
// do query wincontrol children, in case they overlap
Control := ControlAtPos(SmallPointToPoint(MouseMessage.Pos),
                        [capfAllowWinControls]);
if Control is TWinControl then
begin
  // there is a TWinControl child at this position
  // TWinControl children get their own messages
  // => ignore here
  Control := nil;
end;
[/code]
ControlAtPos() searches for TWinControl first (capfAllowWinControls in Flags),
finds one, does not check for children (no capfRecursive in Flags) and returns
the control. And the control is set to nil. (This seems a bit senseless to me)
So, as no control found at mouse position the event handling is given to the
form.

I deleted capfAllowWinControls flag from the call, and it worked as expected
(tested on Windows 7).

I attached example project and a patch, please test.
TagsNo tags attached.
Fixed in Revisionr61053
LazTarget-
WidgetsetWin32/Win64
Attached Files
  • project1.zip (2,295 bytes)
  • handle_mouse_events.patch (836 bytes)
    Index: lcl/include/wincontrol.inc
    ===================================================================
    --- lcl/include/wincontrol.inc	(revision 60767)
    +++ lcl/include/wincontrol.inc	(working copy)
    @@ -4709,15 +4709,7 @@
       else
       begin
         // do query wincontrol children, in case they overlap
    -    Control := ControlAtPos(SmallPointToPoint(MouseMessage.Pos),
    -                            [capfAllowWinControls]);
    -    if Control is TWinControl then
    -    begin
    -      // there is a TWinControl child at this position
    -      // TWinControl children get their own messages
    -      // => ignore here
    -      Control := nil;
    -    end;
    +    Control := ControlAtPos(SmallPointToPoint(MouseMessage.Pos), []);
       end;
     
       //DebugLn(['TWinControl.IsControlMouseMsg B ',DbgSName(Self),' Control=',DbgSName(Control),' Msg=',TheMessage.Msg]);
    
  • 2019-03-25_135656.png (50,085 bytes)
    2019-03-25_135656.png (50,085 bytes)
  • handle_mouse_events_test_project.zip (2,355 bytes)

Activities

ptvs

2019-03-25 10:03

reporter  

project1.zip (2,295 bytes)

ptvs

2019-03-25 10:03

reporter  

handle_mouse_events.patch (836 bytes)
Index: lcl/include/wincontrol.inc
===================================================================
--- lcl/include/wincontrol.inc	(revision 60767)
+++ lcl/include/wincontrol.inc	(working copy)
@@ -4709,15 +4709,7 @@
   else
   begin
     // do query wincontrol children, in case they overlap
-    Control := ControlAtPos(SmallPointToPoint(MouseMessage.Pos),
-                            [capfAllowWinControls]);
-    if Control is TWinControl then
-    begin
-      // there is a TWinControl child at this position
-      // TWinControl children get their own messages
-      // => ignore here
-      Control := nil;
-    end;
+    Control := ControlAtPos(SmallPointToPoint(MouseMessage.Pos), []);
   end;
 
   //DebugLn(['TWinControl.IsControlMouseMsg B ',DbgSName(Self),' Control=',DbgSName(Control),' Msg=',TheMessage.Msg]);

ptvs

2019-03-25 10:03

reporter  

2019-03-25_135656.png (50,085 bytes)
2019-03-25_135656.png (50,085 bytes)

ptvs

2019-04-16 11:52

reporter  

handle_mouse_events_test_project.zip (2,355 bytes)

ptvs

2019-04-16 11:54

reporter   ~0115544

Added test project (handle_mouse_events_test_project.zip) that should work both on Windows and Linux (GTK2)

Juha Manninen

2019-04-24 22:19

developer   ~0115791

Applied, thanks.

Issue History

Date Modified Username Field Change
2019-03-25 10:03 ptvs New Issue
2019-03-25 10:03 ptvs File Added: project1.zip
2019-03-25 10:03 ptvs File Added: handle_mouse_events.patch
2019-03-25 10:03 ptvs File Added: 2019-03-25_135656.png
2019-04-16 11:52 ptvs File Added: handle_mouse_events_test_project.zip
2019-04-16 11:54 ptvs Note Added: 0115544
2019-04-24 22:18 Juha Manninen Assigned To => Juha Manninen
2019-04-24 22:18 Juha Manninen Status new => assigned
2019-04-24 22:19 Juha Manninen Status assigned => resolved
2019-04-24 22:19 Juha Manninen Resolution open => fixed
2019-04-24 22:19 Juha Manninen Fixed in Revision => r61053
2019-04-24 22:19 Juha Manninen LazTarget => -
2019-04-24 22:19 Juha Manninen Widgetset Win32/Win64 => Win32/Win64
2019-04-24 22:19 Juha Manninen Note Added: 0115791