View Issue Details

IDProjectCategoryView StatusLast Update
0025274PatchesWidgetsetpublic2019-02-17 22:18
ReporterJoost van der Sluis Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformAppleOSDarwin 
Product Version1.3 (SVN) 
Summary0025274: Patch to fix selecting an item in a TListView on Carbon when OwnerDraw is true.
DescriptionIt is impossible to select an item in a TListView when OwnerDraw is true on Carbon. This is because the event is cancelled when there are no 'regular' items. And because the event is cancelled when there's never been any item added.
With Ownerdraw set to true both are always the case.
Steps To ReproduceJust open the IDE on Carbon, go to run->attach to program. Try to select one of the programs. You can't. Here the IDE itself uses a TListView with OnwerDraw=true.
TagsNo tags attached.
Fixed in Revision43384
LazTarget-
WidgetsetCarbon
Attached Files

Activities

Joost van der Sluis

2013-11-03 14:16

manager  

ListviewSelectColumnOwnerdraw.patch (2,313 bytes)   
Index: lcl/interfaces/carbon/carbonlistviews.pp
===================================================================
--- lcl/interfaces/carbon/carbonlistviews.pp	(revision 43349)
+++ lcl/interfaces/carbon/carbonlistviews.pp	(working copy)
@@ -134,6 +134,7 @@
       Data: DataBrowserItemDataRef; ASetValue: Boolean): OSStatus; virtual;
     procedure NotificationCallBack(ID: DataBrowserItemId; 
       AMessage: DataBrowserItemNotification); virtual;
+    function IsIndexOutOfRange(ID: DataBrowserItemId): boolean; virtual;
 
   public
     procedure BoundsChanged; override;
@@ -235,6 +236,7 @@
     function GetReadOnly: Boolean; override;
     function MultiSelect: Boolean; override;
     function IsOwnerDrawn: Boolean; override;
+    function IsIndexOutOfRange(ID: DataBrowserItemId): boolean; override;
   public
     constructor Create(const AObject: TWinControl; const AParams: TCreateParams);
     destructor Destroy; override;
@@ -819,7 +821,8 @@
   FItemIndex := -1;
   
   FItemsCheck := TList.Create;
-  
+  NotifySelectionChange := True;
+
   inherited;
 end;
 
@@ -1165,7 +1168,7 @@
 procedure TCarbonDataBrowser.NotificationCallBack(ID: DataBrowserItemId; 
   AMessage: DataBrowserItemNotification); 
 begin
-  if (ID < 1) or (ID > DataBrowserItemId(GetItemsCount)) then Exit;
+  if IsIndexOutOfRange(ID) then  Exit;
 
   if NotifySelectionChange then
     case AMessage of
@@ -1180,6 +1183,11 @@
 
 end;
 
+function TCarbonDataBrowser.IsIndexOutOfRange(ID: DataBrowserItemId): boolean;
+begin
+  result := (ID < 1) or (ID > DataBrowserItemId(GetItemsCount));
+end;
+
 function TCarbonDataBrowser.GetTopItem: Integer;
 begin
   Result := GetItemAt(0, GetHeaderHeight);
@@ -1273,7 +1281,7 @@
 end;
 
 procedure TCarbonDataBrowser.SetItemState(AIndex: Integer;
-  AState: TListItemState; AIsSet: BooleaN);
+  AState: TListItemState; AIsSet: Boolean);
 begin
   case AState of
     lisFocused:
@@ -1620,6 +1628,14 @@
   Result := False; // TODO
 end;
 
+function TCarbonListView.IsIndexOutOfRange(ID: DataBrowserItemId): boolean;
+begin
+  if not FOwnerData then
+    Result:=inherited IsIndexOutOfRange(ID)
+  else
+    result := (ID < 1 ) or (ID > TListView(LCLObject).Items.Count);
+end;
+
 constructor TCarbonListView.Create(const AObject: TWinControl;
   const AParams: TCreateParams);
 begin

Zeljan Rikalo

2013-11-07 07:20

developer   ~0071168

Please test and close if ok. Thanks for the patch.

Issue History

Date Modified Username Field Change
2013-11-03 14:16 Joost van der Sluis New Issue
2013-11-03 14:16 Joost van der Sluis File Added: ListviewSelectColumnOwnerdraw.patch
2013-11-04 09:33 Zeljan Rikalo Assigned To => Zeljan Rikalo
2013-11-04 09:33 Zeljan Rikalo Status new => assigned
2013-11-07 07:20 Zeljan Rikalo Fixed in Revision => 43384
2013-11-07 07:20 Zeljan Rikalo Note Added: 0071168
2013-11-07 07:20 Zeljan Rikalo Status assigned => resolved
2013-11-07 07:20 Zeljan Rikalo Resolution open => fixed
2019-02-17 22:18 Joost van der Sluis Status resolved => closed