Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • Lazarus Lazarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 2.1k
    • Issues 2.1k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 6
    • Merge requests 6
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
    • Model experiments
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • LazarusLazarus
  • LazarusLazarus
  • Issues
  • #36281
Closed
Open
Issue created Nov 07, 2019 by FPC Admin account@fpc_adminOwner

Cocoa: Feature request for ListView SortIndicator

Original Reporter info from Mantis: crlab @neurolabusc1
  • Reporter name: Chris Rorden

Description:

This 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 information:

type
  TCustomTableHeaderCell = objcclass (NSTableHeaderCell)
    listView: TListView;
    procedure drawSortIndicatorWithFrame_inView_ascending_priority (cellFrame: NSRect; controlView_: NSView; ascending: boolean; priority: NSInteger); override;
  end;

procedure TCustomTableHeaderCell.drawSortIndicatorWithFrame_inView_ascending_priority (cellFrame: NSRect; controlView_: NSView; ascending: boolean; priority: NSInteger);
begin
  // 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);
end;

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

  // set custom header cell
  lNSColumn.setHeaderCell(TCustomTableHeaderCell.alloc.init);
  lNSColumn.headerCell.setStringValue(lTitle);
  // 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));

  lNSColumn.setResizingMask(NSTableColumnUserResizingMask);

  lTableLV.addTableColumn(lNSColumn);
  lTitle.release;
end;

Mantis conversion info:

  • Mantis ID: 36281
  • OS: Darwin
  • OS Build: 10.11.6
  • Build: 62218
  • Platform: MacBook 2012 Retina 13"
  • Version: 2.0.7 (SVN)
  • Fixed in revision: 62567 (#556c5562)
Assignee
Assign to
Time tracking