cocoa: implementing column click for a listview #34157

git-svn-id: trunk@58776 -
This commit is contained in:
dmitry 2018-08-25 21:56:41 +00:00
parent 46bb34ff6f
commit 745097e09f
2 changed files with 30 additions and 2 deletions

View File

@ -51,6 +51,7 @@ type
function GetItemTextAt(ARow, ACol: Integer; var Text: String): Boolean;
procedure SetItemTextAt(ARow, ACol: Integer; const Text: String);
procedure tableSelectionChange(ARow: Integer; Added, Removed: NSIndexSet);
procedure ColumnClicked(ACol: Integer);
end;
TCocoaListBox = objcclass;
@ -208,9 +209,9 @@ type
{function tableView_shouldSelectRow(tableView: NSTableView; row: NSInteger): Boolean; message 'tableView:shouldSelectRow:';
function tableView_selectionIndexesForProposedSelection(tableView: NSTableView; proposedSelectionIndexes: NSIndexSet): NSIndexSet; message 'tableView:selectionIndexesForProposedSelection:';
function tableView_shouldSelectTableColumn(tableView: NSTableView; tableColumn: NSTableColumn): Boolean; message 'tableView:shouldSelectTableColumn:';
procedure tableView_mouseDownInHeaderOfTableColumn(tableView: NSTableView; tableColumn: NSTableColumn); message 'tableView:mouseDownInHeaderOfTableColumn:';
procedure tableView_mouseDownInHeaderOfTableColumn(tableView: NSTableView; tableColumn: NSTableColumn); message 'tableView:mouseDownInHeaderOfTableColumn:';}
procedure tableView_didClickTableColumn(tableView: NSTableView; tableColumn: NSTableColumn); message 'tableView:didClickTableColumn:';
procedure tableView_didDragTableColumn(tableView: NSTableView; tableColumn: NSTableColumn); message 'tableView:didDragTableColumn:';
{procedure tableView_didDragTableColumn(tableView: NSTableView; tableColumn: NSTableColumn); message 'tableView:didDragTableColumn:';
function tableView_toolTipForCell_rect_tableColumn_row_mouseLocation(tableView: NSTableView; cell: NSCell; rect: NSRectPointer; tableColumn: NSTableColumn; row: NSInteger; mouseLocation: NSPoint): NSString; message 'tableView:toolTipForCell:rect:tableColumn:row:mouseLocation:';
function tableView_heightOfRow(tableView: NSTableView; row: NSInteger): CGFloat; message 'tableView:heightOfRow:';
function tableView_typeSelectStringForTableColumn_row(tableView: NSTableView; tableColumn: NSTableColumn; row: NSInteger): NSString; message 'tableView:typeSelectStringForTableColumn:row:';
@ -877,6 +878,13 @@ begin
Result := true;
end;
procedure TCocoaTableListView.tableView_didClickTableColumn(
tableView: NSTableView; tableColumn: NSTableColumn);
begin
if Assigned(callback) then
callback.ColumnClicked(getIndexOfColumn(tableColumn));
end;
type
TCompareData = record
rmved : NSMutableIndexSet;

View File

@ -235,6 +235,7 @@ type
function GetItemTextAt(ARow, ACol: Integer; var Text: String): Boolean;
procedure SetItemTextAt(ARow, ACol: Integer; const Text: String);
procedure tableSelectionChange(NewSel: Integer; Added, Removed: NSIndexSet);
procedure ColumnClicked(ACol: Integer);
end;
TLCLListViewCallBackClass = class of TLCLListViewCallback;
@ -1413,6 +1414,25 @@ begin
LCLMessageGlue.DeliverMessage(ListView, Msg);}
end;
procedure TLCLListViewCallback.ColumnClicked(ACol: Integer);
var
Msg: TLMNotify;
NMLV: TNMListView;
begin
FillChar(Msg{%H-}, SizeOf(Msg), #0);
FillChar(NMLV{%H-}, SizeOf(NMLV), #0);
Msg.Msg := CN_NOTIFY;
NMLV.hdr.hwndfrom := ListView.Handle;
NMLV.hdr.code := LVN_COLUMNCLICK;
NMLV.iSubItem := ACol;
NMLV.uChanged := 0;
Msg.NMHdr := @NMLV.hdr;
LCLMessageGlue.DeliverMessage(ListView, Msg);
end;
{ TCocoaWSTrackBar }
{------------------------------------------------------------------------------