diff --git a/lcl/interfaces/carbon/carbondef.pp b/lcl/interfaces/carbon/carbondef.pp index 0427dbd1b4..e25d0e3cdc 100644 --- a/lcl/interfaces/carbon/carbondef.pp +++ b/lcl/interfaces/carbon/carbondef.pp @@ -87,6 +87,7 @@ type procedure ControlAdded; dynamic; function FilterKeyPress(SysKey: Boolean; const Char: TUTF8Char): Boolean; dynamic; procedure ProcessKeyEvent(const msg: TLMKey; var Result: OSStatus); virtual; + function NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean; virtual; public constructor Create(const AObject: TWinControl; const AParams: TCreateParams); destructor Destroy; override; @@ -614,6 +615,11 @@ procedure TCarbonWidget.ProcessKeyEvent(const msg: TLMKey; var Result: OSStatus) begin end; +function TCarbonWidget.NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean; +begin + Result := true; +end; + {------------------------------------------------------------------------------ Method: TCarbonWidget.Create Params: AObject - LCL conrol diff --git a/lcl/interfaces/carbon/carbonlistviews.pp b/lcl/interfaces/carbon/carbonlistviews.pp index 2b499b6bbb..42c2d2ec54 100644 --- a/lcl/interfaces/carbon/carbonlistviews.pp +++ b/lcl/interfaces/carbon/carbonlistviews.pp @@ -211,6 +211,8 @@ type procedure UpdateColumnView; override; procedure ClearIconCache; + + function NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean; override; end; { TCarbonListBox } @@ -404,7 +406,9 @@ function TCarbonListColumn.GetHeaderPropertyFlags: Integer; begin Result := kDataBrowserPropertyIsMutable or kDataBrowserListViewSelectionColumn or - kDataBrowserListViewTypeSelectColumn; + kDataBrowserListViewTypeSelectColumn or + kDataBrowserListViewSortableColumn or + kDataBrowserListViewMovableColumn; end; constructor TCarbonListColumn.Create(AOwner: TCarbonDataBrowser; @@ -1601,6 +1605,38 @@ begin FIcons.Clear; end; +function TCarbonListView.NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean; +var + h : UInt16; + y : Integer; +type + PLMMouse = ^TLMMouse; + PLMMouseMove = ^TLMMouseMove; + +// for some unkown reason, HIViewConvertPoint does return inaccurate x,y position for ListView +// (because of focus ring?) +const + OfsY = -2; +begin + if Assigned(LCLObject) and (TListView(LCLObject).Columns.Count > 0) and + (TListView(LCLObject).ViewStyle = vsReport) then + begin + case Msg of + LM_LBUTTONDOWN..LM_MBUTTONDBLCLK: y := PLMMouse(@AMessage)^.YPos; + LM_MOUSEMOVE: y := PLMMouseMove(@AMessage)^.YPos ; + LM_MOUSEWHEEL: y := PLMMouseEvent(@AMessage)^.Y; + else + Result := inherited NeedDeliverMouseEvent(msg, AMessage); + Exit; + end; + GetDataBrowserListViewHeaderBtnHeight(Content, h); + inc(y, OfsY); + Result := y > h; + end + else + Result := inherited NeedDeliverMouseEvent(msg, AMessage); +end; + { TCarbonListBox } procedure TCarbonListBox.CreateWidget(const AParams: TCreateParams); diff --git a/lcl/interfaces/carbon/carbonprivatecommon.inc b/lcl/interfaces/carbon/carbonprivatecommon.inc index 25b0df96cb..89802cf33e 100644 --- a/lcl/interfaces/carbon/carbonprivatecommon.inc +++ b/lcl/interfaces/carbon/carbonprivatecommon.inc @@ -173,8 +173,12 @@ begin Msg.XPos := P.X; Msg.YPos := P.Y; Msg.Keys := GetCarbonMsgKeyState; - NotifyApplicationUserInput(Msg.Msg); - DeliverMessage(Widget.LCLObject, Msg); + + if Widget.NeedDeliverMouseEvent(Msg.Msg, Msg) then + begin + NotifyApplicationUserInput(Msg.Msg); + DeliverMessage(Widget.LCLObject, Msg); + end; end; end; @@ -208,8 +212,11 @@ begin if PostponedDown then begin PostponedDown := False; - NotifyApplicationUserInput(PostponedDownMsg.Msg); - DeliverMessage(AWidget.LCLObject, PostponedDownMsg); + if AWidget.NeedDeliverMouseEvent(PostponedDownMsg.Msg, PostponedDownMsg) then + begin + NotifyApplicationUserInput(PostponedDownMsg.Msg); + DeliverMessage(AWidget.LCLObject, PostponedDownMsg); + end; end; MouseButton := GetCarbonMouseButton(AEvent); @@ -262,10 +269,13 @@ begin end; end; - DeliverMessage(AWidget.LCLObject, Msg); + if AWidget.NeedDeliverMouseEvent(Msg.Msg, Msg) then + begin + DeliverMessage(AWidget.LCLObject, Msg); - NotifyApplicationUserInput(Msg.Msg); - CarbonWidgetSet.SetCaptureWidget(0); // capture is released + NotifyApplicationUserInput(Msg.Msg); + CarbonWidgetSet.SetCaptureWidget(0); // capture is released + end; end; {------------------------------------------------------------------------------ diff --git a/lcl/interfaces/carbon/carbonprivatewindow.inc b/lcl/interfaces/carbon/carbonprivatewindow.inc index 1434b211dc..b72a3003d1 100644 --- a/lcl/interfaces/carbon/carbonprivatewindow.inc +++ b/lcl/interfaces/carbon/carbonprivatewindow.inc @@ -81,7 +81,7 @@ const SName, SGetEvent, 'kEventParamClickCount') then Exit; Result := ClickCount; - //debugln('GetClickCount ClickCount=',dbgs(ClickCount)); + {debugln('GetClickCount ClickCount=',dbgs(ClickCount));} end; function GetMousePoint: TPoint; @@ -141,9 +141,9 @@ const ClickCount := GetClickCount; MouseButton := GetCarbonMouseButton(AEvent); MousePoint := GetMousePoint; - + if (ClickCount < Low(MSGKIND)) or (ClickCount > High(MSGKIND)) then - ClickCount := 1; + ClickCount := (ClickCount mod High(MSGKIND))+1; if (MouseButton < Low(MSGKIND[1])) or (MouseButton > High(MSGKIND[1])) then Exit; Msg^.Msg := MSGKIND[ClickCount, MouseButton]; @@ -296,14 +296,18 @@ begin end else begin - // Msg is set in the Appropriate HandleMousexxx procedure - NotifyApplicationUserInput(Msg.Message.Msg); - if DeliverMessage(Widget.LCLObject, Msg) = 0 then - begin - Result := EventNotHandledErr; + if Widget.NeedDeliverMouseEvent(Msg.Message.Msg, Msg) then begin + // Msg is set in the Appropriate HandleMousexxx procedure + NotifyApplicationUserInput(Msg.Message.Msg); + if DeliverMessage(Widget.LCLObject, Msg) = 0 then + begin + Result := EventNotHandledErr; + end + else // the LCL does not want the event propagated + Result := noErr; end - else // the LCL does not want the event propagated - Result := noErr; + else + Result := CallNextEventHandler(ANextHandler, AEvent); end; // interactive design