View Issue Details

IDProjectCategoryView StatusLast Update
0036281LazarusWidgetsetpublic2019-11-07 21:22
ReporterChris RordenAssigned To 
Status newResolutionopen 
PlatformMacBook 2012 Retina 13"OSDarwinOS Version10.11.6
Product Version2.0.7 (SVN)Product Build62218 
Target VersionFixed in Version 
Summary0036281: Cocoa: Feature request for ListView SortIndicator
DescriptionThis is a want not need, as this feature does not exist with Lazarus on Windows or Linux. However, it would make Tables in MacOS look more native. It would be great if the Cocoa ListViews could show a SortIndicator at the top of the column used for a sort. Ryan Joseph wrote a skeleton code to implement this (see attached screenshot), and it would be great if this indicated the column that was sorted and the sort direction.
Additional Informationtype
  TCustomTableHeaderCell = objcclass (NSTableHeaderCell)
    listView: TListView;
    procedure drawSortIndicatorWithFrame_inView_ascending_priority (cellFrame: NSRect; controlView_: NSView; ascending: boolean; priority: NSInteger); override;

procedure TCustomTableHeaderCell.drawSortIndicatorWithFrame_inView_ascending_priority (cellFrame: NSRect; controlView_: NSView; ascending: boolean; priority: NSInteger);
  // manually set the ascending flag to match the current sorting order in the TListView
  inherited drawSortIndicatorWithFrame_inView_ascending_priority(cellFrame, controlView_, false{listView.SortDirection=sdAscending}, priority);

class procedure TCocoaWSCustomListView.ColumnInsert(const ALV: TCustomListView;
  const AIndex: Integer; const AColumn: TListColumn);
  lTableLV: TCocoaTableListView;
  lNSColumn: NSTableColumn;
  lTitle: NSString;
  sc: TCocoaListView;
  WriteLn(Format('[TCocoaWSCustomListView.ColumnInsert] ALV=%x AIndex=%d', [PtrInt(ALV), AIndex]));
  //if not Assigned(ALV) or not ALV.HandleAllocated then Exit;
  //lTableLV := TCocoaTableListView(TCocoaListView(ALV.Handle).documentView);
  if not CheckParams(sc, lTableLV, ALV) then Exit;
  WriteLn(Format('[TCocoaWSCustomListView.ColumnInsert]=> tableColumns.count=%d', [lTableLV.tableColumns.count()]));
  if (AIndex < 0) or (AIndex >= lTableLV.tableColumns.count()+1) then Exit;
  lTitle := NSStringUTF8(AColumn.Caption);
  lNSColumn := NSTableColumn.alloc.initWithIdentifier(lTitle);

  // set custom header cell
  // set a reference to the TListView but I'm not sure how
  TCustomTableHeaderCell(lNSColumn.headerCell).listView := nil;
  // set the NSSortDescriptor so NSTableView draws the arrows
  lNSColumn.setSortDescriptorPrototype(NSSortDescriptor.sortDescriptorWithKey_ascending(lNSColumn.identifier, true));


TagsNo tags attached.
Fixed in Revision
Attached Files


Chris Rorden

2019-11-07 21:22


sort.png (5,218 bytes)
sort.png (5,218 bytes)

Issue History

Date Modified Username Field Change
2019-11-07 21:22 Chris Rorden New Issue
2019-11-07 21:22 Chris Rorden File Added: sort.png