Cocoa: fix the check/select state of CheckListBox to ListControl

This commit is contained in:
rich2014 2024-08-18 00:20:42 +08:00
parent 99646bc91e
commit 5f125f2f4c
5 changed files with 163 additions and 228 deletions

View File

@ -38,6 +38,7 @@ type
function selectionIndexSet: NSMutableIndexSet;
function checkedIndexSet: NSMutableIndexSet;
function shouldSelectionChange(NewSel: Integer): Boolean;
function getItemStableSelection(ARow: Integer): Boolean;
procedure ColumnClicked(ACol: Integer);
function onAddSubview( aView:NSView ): Boolean;
@ -56,8 +57,11 @@ type
public
constructor Create(AOwner: NSObject; ATarget: TWinControl; AHandleFrame: NSView = nil); override;
destructor Destroy; override;
function selectionIndexSet: NSMutableIndexSet;
function checkedIndexSet: NSMutableIndexSet;
function selectionIndexSet: NSMutableIndexSet; virtual;
function checkedIndexSet: NSMutableIndexSet; virtual;
function GetItemCheckedAt( row: Integer; var CheckState: Integer): Boolean; virtual;
procedure SetItemCheckedAt( row: Integer; CheckState: Integer); virtual;
function getItemStableSelection(ARow: Integer): Boolean; virtual;
public
function ItemsCount: Integer; virtual; abstract;
procedure GetRowHeight(rowidx: Integer; var height: Integer); virtual; abstract;
@ -65,15 +69,11 @@ type
function GetImageListType( out lvil: TListViewImageList ): Boolean; virtual; abstract;
function GetItemTextAt(ARow, ACol: Integer; var Text: String): Boolean; virtual; abstract;
function GetItemCheckedAt( row: Integer; var CheckState: Integer): Boolean; virtual; abstract;
function GetItemImageAt(ARow, ACol: Integer; var imgIdx: Integer): Boolean; virtual; abstract;
function GetImageFromIndex(imgIdx: Integer): NSImage; virtual; abstract;
procedure SetItemTextAt(ARow, ACol: Integer; const Text: String); virtual; abstract;
procedure SetItemCheckedAt( row: Integer; CheckState: Integer); virtual; abstract;
function shouldSelectionChange(NewSel: Integer): Boolean; virtual; abstract;
procedure ColumnClicked(ACol: Integer); virtual; abstract;
function onAddSubview( aView:NSView ): Boolean; virtual; abstract;
@ -153,6 +153,29 @@ begin
Result:= _checkedIndexSet;
end;
function TLCLListControlCallback.GetItemCheckedAt(row: Integer;
var CheckState: Integer): Boolean;
var
BoolState : array [Boolean] of Integer = (NSOffState, NSOnState);
begin
CheckState := BoolState[self.checkedIndexSet.containsIndex(row)];
Result := true;
end;
procedure TLCLListControlCallback.SetItemCheckedAt(row: Integer;
CheckState: Integer);
begin
if CheckState = NSOnState then
self.checkedIndexSet.addIndex( row )
else
self.checkedIndexSet.removeIndex( row );
end;
function TLCLListControlCallback.getItemStableSelection(ARow: Integer): Boolean;
begin
Result:= selectionIndexSet.containsIndex( ARow );
end;
{ TCocoaTableListControlProcessor }
function TCocoaTableListControlProcessor.getCallback(tv: NSTableView

View File

@ -108,7 +108,6 @@ type
function GetBorderStyle: TBorderStyle; override;
function onAddSubview(aView: NSView): Boolean; override;
function getItemStableSelection(ARow: Integer): Boolean;
procedure selectOne(ARow: Integer; isSelected:Boolean );
procedure callTargetInitializeWnd;
end;
@ -354,13 +353,11 @@ function TLCLListViewCallback.GetItemCheckedAt( row: Integer;
var IsChecked: Integer): Boolean;
var
BoolState : array [Boolean] of Integer = (NSOffState, NSOnState);
indexSet: NSIndexSet;
begin
indexSet:= self.checkedIndexSet;
if ownerData and Assigned(listView) and (row>=0) and (row < listView.Items.Count) then
IsChecked := BoolState[listView.Items[row].Checked]
else
IsChecked := BoolState[checkedIndexSet.containsIndex(row)];
Inherited GetItemCheckedAt( row, IsChecked );
Result := true;
end;
@ -465,9 +462,7 @@ var
Msg: TLMNotify;
NMLV: TNMListView;
begin
if IsChecked = NSOnState
then checkedIndexSet.addIndex(row)
else checkedIndexSet.removeIndex(row);
Inherited;
FillChar(Msg{%H-}, SizeOf(Msg), #0);
FillChar(NMLV{%H-}, SizeOf(NMLV), #0);
@ -484,11 +479,6 @@ begin
LCLMessageGlue.DeliverMessage(ListView, Msg);
end;
function TLCLListViewCallback.getItemStableSelection(ARow: Integer): Boolean;
begin
Result:= selectionIndexSet.containsIndex( ARow );
end;
procedure TLCLListViewCallback.selectOne(ARow: Integer; isSelected: Boolean);
procedure sendMsgToLCL;
var

View File

@ -98,6 +98,7 @@ type
procedure lclInsertItem(const AIndex: Integer); message 'lclInsertItem:';
procedure lclDeleteItem(const AIndex: Integer); message 'lclDeleteItem:';
procedure lclExchangeItem(const AIndex1: Integer; const AIndex2: Integer); message 'lclExchangeItem:AIndex2:';
procedure lclClearItem; message 'lclClearItem';
procedure checkboxAction(sender: NSButton); message 'checkboxAction:';
function acceptsFirstResponder: LCLObjCBoolean; override;
@ -1323,6 +1324,38 @@ begin
self.reloadData;
end;
procedure ExchangeIndexSetItem( indexSet: NSMutableIndexSet;
const AIndex1: Integer; const AIndex2: Integer );
var
hasIndex1: Boolean;
hasIndex2: Boolean;
begin
hasIndex1:= indexSet.containsIndex(AIndex1);
hasIndex2:= indexSet.containsIndex(AIndex2);
if hasIndex1 = hasIndex2 then
Exit;
if hasIndex1 then begin
indexSet.removeIndex( AIndex1 );
indexSet.addIndex( AIndex2 );
end;
if hasIndex2 then begin
indexSet.removeIndex( AIndex2 );
indexSet.addIndex( AIndex1 );
end;
end;
procedure TCocoaTableListView.lclExchangeItem(const AIndex1: Integer;
const AIndex2: Integer);
begin
if NOT Assigned(self.callback) then
Exit;
ExchangeIndexSetItem( self.callback.checkedIndexSet, AIndex1, AIndex2 );
ExchangeIndexSetItem( self.callback.selectionIndexSet, AIndex1, AIndex2 );
self.reloadData;
end;
procedure TCocoaTableListView.lclClearItem;
begin
self.callback.checkedIndexSet.removeAllIndexes;

View File

@ -34,18 +34,6 @@ uses
type
{ TCocoaCheckStringList }
TCocoaCheckStringList = class(TCocoaListBoxStringList)
protected
procedure ExchangeItems(Index1, Index2: Integer); override;
public
ChkState : array of SInt8;
procedure InsertItem(Index: Integer; const S: string; O: TObject); override;
procedure Delete(Index: Integer); override;
procedure Clear; override;
end;
{ TLCLCheckboxListCallback }
TLCLCheckboxListCallback = class(TLCLListBoxCallback)
@ -54,14 +42,9 @@ type
public
checklist: TCustomCheckListBox;
constructor Create(AOwner: NSObject; ATarget: TWinControl; AHandleView: NSView); override;
function GetItemCheckedAt( row: Integer; var CheckState: Integer): Boolean; override;
procedure SetItemCheckedAt( row: Integer; CheckState: Integer); override;
function GetCheckState(Index: Integer; var AState: Integer): Boolean;
function SetCheckState(Index: Integer; AState: Integer; InvalidateCocoa: Boolean = true): Boolean;
end;
{ TCocoaWSCustomCheckListBox }
TCocoaWSCustomCheckListBox = class(TWSCustomCheckListBox)
@ -73,73 +56,11 @@ type
implementation
function CtrlToCheckList(ctrl: TWinControl; out tbl: TCocoaTableListView; out cb: TLCLCheckboxListCallback): Boolean;
begin
Result := Assigned(ctrl) and (ctrl.HandleAllocated) and (ctrl.Handle <> 0);
if not Result then begin
tbl := nil;
cb := nil;
Exit;
end;
tbl:=TCocoaTableListView(NSSCrollView(ctrl.Handle).documentView);
Result := Assigned(tbl);
if Result then
cb := TLCLCheckboxListCallback(tbl.lclGetCallback.GetCallbackObject)
else
cb := nil;
end;
{ TCocoaCheckStringList }
procedure TCocoaCheckStringList.ExchangeItems(Index1, Index2: Integer);
var
t : Integer;
begin
inherited ExchangeItems(Index1, Index2);
t := ChkState[Index1];
ChkState[Index1] := ChkState[Index2];
ChkState[Index2] := t;
end;
procedure TCocoaCheckStringList.InsertItem(Index: Integer; const S: string;
O: TObject);
var
cnt : integer;
sz : integer;
begin
cnt := Count;
inherited InsertItem(Index, S, O);
if length(ChkState)<Capacity then
SetLength(ChkState, Capacity);
sz := (cnt - Index) * sizeof(SInt8);
if sz>0 then System.Move(ChkState[Index], ChkState[Index+1], sz);
ChkState[Index] := 0;
end;
procedure TCocoaCheckStringList.Delete(Index: Integer);
var
sz : Integer;
begin
inherited Delete(Index);
sz := (Count - Index) * sizeof(SInt8);
if (sz>0) and (Index < Count) then
System.Move(ChkState[Index+1], ChkState[Index], sz);
end;
procedure TCocoaCheckStringList.Clear;
begin
inherited Clear;
SetLength(ChkState, 0);
end;
{ TLCLCheckboxListCallback }
function TLCLCheckboxListCallback.AllocStrings(ATable: NSTableView): TCocoaListControlStringList;
begin
Result:=TCocoaCheckStringList.Create(ATable);
Result:=TCocoaListBoxStringList.Create(ATable);
end;
constructor TLCLCheckboxListCallback.Create(AOwner: NSObject; ATarget: TWinControl; AHandleView: NSView);
@ -149,50 +70,11 @@ begin
checklist := TCustomCheckListBox(ATarget);
end;
function TLCLCheckboxListCallback.GetItemCheckedAt( row: Integer;
var CheckState: Integer): Boolean;
begin
Result := GetCheckState(row, CheckState);
end;
procedure TLCLCheckboxListCallback.SetItemCheckedAt( row: Integer;
CheckState: Integer);
var
changed : Boolean;
begin
changed := SetCheckState(row, CheckState, false); // returns true, if changed!s
if changed then LCLSendChangedMsg(Target, row);
end;
function TLCLCheckboxListCallback.GetCheckState(Index: Integer; var AState: Integer): Boolean;
var
chkstr : TCocoaCheckStringList;
begin
Result := Assigned(strings) and (Index>=0) and (Index<strings.Count);
if Result then
begin
chkstr := TCocoaCheckStringList(strings);
AState := chkstr.ChkState[Index];
end
else
ASTate := 0;
end;
function TLCLCheckboxListCallback.SetCheckState(Index: Integer; AState: Integer;
InvalidateCocoa: Boolean = true): Boolean;
var
chkstr : TCocoaCheckStringList;
begin
Result := Assigned(Strings) and (Index>=0) and (Index<strings.Count);
if not Result then Exit;
chkstr := TCocoaCheckStringList(strings);
Result := chkstr.ChkState[Index] <> AState;
if Result then
begin
chkstr.ChkState[Index] := AState;
if InvalidateCocoa and Assigned(listview) then
listview.reloadDataForRow_column(Index, 0);
end;
Inherited;
LCLSendChangedMsg( self.Target, row );
end;
{ TCocoaWSCustomCheckListBox }
@ -211,6 +93,7 @@ var
list: TCocoaTableListView;
scroll: TCocoaScrollView;
processor: TCocoaTableViewProcessor;
lclCheckListBox: TCustomCheckListBox absolute AWinControl;
begin
list := AllocCocoaTableListView.lclInitWithCreateParams(AParams);
if not Assigned(list) then
@ -227,10 +110,11 @@ begin
list.setHeaderView(nil);
list.setDataSource(list);
list.setDelegate(list);
list.setAllowsMultipleSelection(lclCheckListBox.MultiSelect);
list.readOnly := true;
//todo:
//list.AllowMixedState := TCustomCheckListBox(AWinControl).AllowGrayed;
list.isOwnerDraw := TCustomCheckListBox(AWinControl).Style in [lbOwnerDrawFixed, lbOwnerDrawVariable];
list.isOwnerDraw := lclCheckListBox.Style in [lbOwnerDrawFixed, lbOwnerDrawVariable];
scroll := EmbedInScrollView(list);
if not Assigned(scroll) then
@ -242,7 +126,7 @@ begin
scroll.setHasVerticalScroller(true);
scroll.setAutohidesScrollers(true);
ScrollViewSetBorderStyle(scroll, TCustomCheckListBox(AWinControl).BorderStyle);
ScrollViewSetBorderStyle(scroll, lclCheckListBox.BorderStyle);
UpdateControlFocusRing(list, AWinControl);
Result := TLCLHandle(scroll);
@ -258,23 +142,19 @@ end;
class function TCocoaWSCustomCheckListBox.GetState(
const ACheckListBox: TCustomCheckListBox; const AIndex: integer): TCheckBoxState;
var
tbl: TCocoaTableListView;
cb : TLCLCheckboxListCallback;
cocoaSt: Integer;
lclcb : TLCLCheckboxListCallback;
checkState: Integer;
begin
if not CtrlToCheckList(ACheckListBox, tbl, cb) then begin
Result := cbUnchecked;
Result:= cbUnchecked;
lclcb:= TLCLCheckboxListCallback( getCallbackFromLCLListBox(ACheckListBox) );
if NOT Assigned(lclcb) then
Exit;
if lclcb.GetItemCheckedAt(AIndex, checkState) then begin
if checkState <> NSOffState then
Result:= cbChecked;
end;
if cb.GetCheckState(AIndex, cocoaSt) then
case cocoaSt of
NSOnState : Result := cbChecked;
NSMixedState : Result := cbGrayed;
else
Result := cbUnchecked;
end
else
Result := cbUnchecked;
end;
{------------------------------------------------------------------------------
@ -290,19 +170,23 @@ class procedure TCocoaWSCustomCheckListBox.SetState(
const ACheckListBox: TCustomCheckListBox; const AIndex: integer;
const AState: TCheckBoxState);
var
tbl: TCocoaTableListView;
cb : TLCLCheckboxListCallback;
cocoaSt: Integer;
cocoaTLV: TCocoaTableListView;
lclcb : TLCLCheckboxListCallback;
checkState: Integer;
begin
if not CtrlToCheckList(ACheckListBox, tbl, cb) then Exit;
lclcb:= TLCLCheckboxListCallback( getCallbackFromLCLListBox(ACheckListBox) );
if NOT Assigned(lclcb) then
Exit;
case AState of
cbChecked: cocoaSt := NSOnState;
cbGrayed: cocoaSt := NSMixedState;
if AState <> cbUnchecked then
checkState:= NSOnState
else
cocoaSt := NSOffState;
end;
cb.SetCheckState(AIndex, cocoaSt, true);
checkState:= NSOffState;
lclcb.SetItemCheckedAt( AIndex, checkState );
cocoaTLV:= getTableViewFromLCLListBox( ACheckListBox );
cocoaTLV.reloadDataForRow_column( AIndex, 0 );
end;
end.

View File

@ -279,11 +279,9 @@ type
function ItemsCount: Integer; override;
function GetImageListType(out lvil: TListViewImageList): Boolean; override;
function GetItemTextAt(ARow, ACol: Integer; var Text: String): Boolean; override;
function GetItemCheckedAt( row: Integer; var isChecked: Integer): Boolean; override;
function GetItemImageAt(ARow, ACol: Integer; var imgIdx: Integer): Boolean; override;
function GetImageFromIndex(imgIdx: Integer): NSImage; override;
procedure SetItemTextAt(ARow, ACol: Integer; const Text: String); override;
procedure SetItemCheckedAt( row: Integer; isChecked: Integer); override;
function shouldSelectionChange(NewSel: Integer): Boolean; override;
procedure ColumnClicked(ACol: Integer); override;
function drawItem( row: Integer; ctx: TCocoaContext; const r: TRect;
@ -300,9 +298,11 @@ type
{ TCocoaListBoxStringList }
TCocoaListBoxStringList = class( TCocoaListControlStringList )
public
protected
procedure InsertItem(Index: Integer; const S: string; O: TObject); override;
public
procedure Delete(Index: Integer); override;
procedure Exchange(Index1, Index2: Integer); override;
procedure Clear; override;
end;
@ -377,7 +377,10 @@ function AllocButton(const ATarget: TWinControl; const ACallBackClass: TLCLButto
function AllocTextField(ATarget: TWinControl; const AParams: TCreateParams): TCocoaTextField;
function AllocSecureTextField(ATarget: TWinControl; const AParams: TCreateParams): TCocoaSecureTextField;
function GetListBox(AWinControl: TWinControl): TCocoaTableListView;
function getCallbackFromLCLListBox( const AListBox: TCustomListBox ):
TLCLListBoxCallback;
function getTableViewFromLCLListBox( const AListBox: TCustomListBox ):
TCocoaTableListView;
procedure ListBoxSetStyle(list: TCocoaTableListView; AStyle: TListBoxStyle);
procedure TextViewSetWordWrap(txt: NSTextView; lScroll: NSScrollView; NewWordWrap: Boolean);
@ -645,12 +648,6 @@ begin
if Result then Text := strings[ARow];
end;
function TLCLListBoxCallback.GetItemCheckedAt( row: Integer;
var isChecked: Integer): Boolean;
begin
Result := false;
end;
function TLCLListBoxCallback.GetItemImageAt(ARow, ACol: Integer;
var imgIdx: Integer): Boolean;
begin
@ -668,12 +665,6 @@ begin
// todo:
end;
procedure TLCLListBoxCallback.SetItemCheckedAt( row: Integer;
isChecked: Integer);
begin
// do nothing
end;
function TLCLListBoxCallback.shouldSelectionChange(NewSel: Integer
): Boolean;
begin
@ -734,19 +725,25 @@ end;
procedure TCocoaListBoxStringList.InsertItem(Index: Integer; const S: string;
O: TObject);
begin
inherited InsertItem(Index, S, O);
inherited;
TCocoaTableListView(self.Owner).lclInsertItem(Index);
end;
procedure TCocoaListBoxStringList.Delete(Index: Integer);
begin
inherited Delete(Index);
inherited;
TCocoaTableListView(self.Owner).lclDeleteItem(Index);
end;
procedure TCocoaListBoxStringList.Exchange(Index1, Index2: Integer);
begin
inherited;
TCocoaTableListView(self.Owner).lclExchangeItem(Index1, Index2);
end;
procedure TCocoaListBoxStringList.Clear;
begin
inherited Clear;
inherited;
TCocoaTableListView(self.Owner).lclClearItem();
end;
@ -2421,24 +2418,29 @@ end;
{ TCocoaWSCustomListBox }
function GetListBox(AWinControl: TWinControl): TCocoaTableListView;
function getTableViewFromLCLListBox( const AListBox: TCustomListBox ):
TCocoaTableListView;
var
scrollView: NSScrollView;
begin
if not Assigned(AWinControl) or (AWinControl.Handle=0) then
Result := nil
else
Result := TCocoaTableListView(TCocoaScrollView(AWinControl.Handle).documentView);
Result:= nil;
if NOT Assigned(AListBox) or NOT AListBox.HandleAllocated then
Exit;
scrollView:= NSSCrollView( AListBox.Handle );
Result:= TCocoaTableListView( scrollView.documentView );
end;
function GetListBoxWithCb(AWinControl: TWinControl; out cb: TLCLListBoxCallback): TCocoaTableListView;
function getCallbackFromLCLListBox( const AListBox: TCustomListBox ):
TLCLListBoxCallback;
var
cocoaListView: TCocoaTableListView;
begin
Result := GetListBox(AWinControl);
if not Assigned(Result) then
cb := nil
else
cb := TLCLListBoxCallback(Result.lclGetCallback.GetCallbackObject)
Result:= nil;
cocoaListView:= getTableViewFromLCLListBox( AListBox );
if Assigned(cocoaListView) then
Result:= TLCLListBoxCallback( cocoaListView.callback );
end;
procedure ListBoxSetStyle(list: TCocoaTableListView; AStyle: TListBoxStyle);
begin
if not Assigned(list) then Exit;
@ -2451,12 +2453,12 @@ end;
class procedure TCocoaWSCustomListBox.DragStart(
const ACustomListBox: TCustomListBox);
var
view: TCocoaTableListView;
cb : TLCLListBoxCallback;
lclcb : TLCLListBoxCallback;
begin
view := GetListBoxWithCb(ACustomListBox, cb);
if not Assigned(view) or not Assigned(cb) then Exit;
cb.BlockCocoaMouseMove:=true;
lclcb:= getCallbackFromLCLListBox( ACustomListBox );
if NOT Assigned(lclcb) then
Exit;
lclcb.BlockCocoaMouseMove:=true;
end;
function TCocoaTableListBoxProcessor.isInitializing(tv: NSTableView): Boolean;
@ -2475,6 +2477,8 @@ begin
lclcb:= TLCLListBoxCallback( cocoaTLV.callback );
lclListBox:= TCustomListBox( lclcb.Target );
if lclListBox = nil then
Exit;
// do not notify about selection changes while clearing
if Assigned(lclcb.strings) and (lclcb.strings.isClearing) then Exit;
@ -2548,7 +2552,7 @@ var
list: TCocoaTableListView;
lPoint: NSPoint;
begin
list := GetListBox(ACustomListBox);
list := getTableViewFromLCLListBox(ACustomListBox);
if not Assigned(list) then
begin
Result:=-1;
@ -2565,7 +2569,7 @@ var
begin
Result := False;
view := GetListBox(ACustomListBox);
view := getTableViewFromLCLListBox(ACustomListBox);
if not Assigned(view) then Exit(False);
Result := LCLGetItemRect(view, Index, 0, ARect);
end;
@ -2574,7 +2578,7 @@ class function TCocoaWSCustomListBox.GetScrollWidth(const ACustomListBox: TCusto
var
view: TCocoaTableListView;
begin
view := GetListBox(ACustomListBox);
view := getTableViewFromLCLListBox(ACustomListBox);
if not Assigned(view) then Exit(0);
Result := view.ScrollWidth;
end;
@ -2584,7 +2588,7 @@ var
view: TCocoaTableListView;
indexset: NSIndexSet;
begin
view:=GetListBox(ACustomListBox);
view:=getTableViewFromLCLListBox(ACustomListBox);
if not Assigned(view) then Exit(-1);
indexset:=view.selectedRowIndexes();
@ -2599,7 +2603,7 @@ var
view: TCocoaTableListView;
selection: NSIndexSet;
begin
view := GetListBox(ACustomListBox);
view := getTableViewFromLCLListBox(ACustomListBox);
if not Assigned(view) then Exit(0);
selection := view.selectedRowIndexes();
Result := selection.count();
@ -2611,7 +2615,7 @@ var
view: TCocoaTableListView;
selection: NSIndexSet;
begin
view := GetListBox(ACustomListBox);
view := getTableViewFromLCLListBox(ACustomListBox);
if not Assigned(view) then Exit(False);
if AIndex < 0 then Exit(False);
selection := view.selectedRowIndexes();
@ -2620,35 +2624,36 @@ end;
class function TCocoaWSCustomListBox.GetStrings(const ACustomListBox: TCustomListBox):TStrings;
var
view: TCocoaTableListView;
cb : TLCLListBoxCallback;
lclcb : TLCLListBoxCallback;
begin
view := GetListBoxWithCb(ACustomListBox, cb);
if not Assigned(view) then Exit(nil);
Result := cb.strings;
lclcb:= getCallbackFromLCLListBox( ACustomListBox );
if NOT Assigned(lclcb) then
Exit;
Result:= lclcb.strings;
end;
class function TCocoaWSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox): integer;
var
view: TCocoaTableListView;
begin
view := GetListBox(ACustomListBox);
view := getTableViewFromLCLListBox(ACustomListBox);
if not Assigned(view) then Exit(-1);
Result := LCLGetTopRow(view);
end;
class procedure TCocoaWSCustomListBox.SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean);
var
list: TCocoaTableListView;
cocoaTLV:TCocoaTableListView;
lclcb: TLCLListBoxCallback;
begin
list := GetListBox(ACustomListBox);
if not Assigned(list) then Exit();
if ASelected then
begin
list.selectRowIndexes_byExtendingSelection(NSIndexSet.indexSetWithIndex(AIndex), True)
end
else
list.deselectRow(AIndex);
lclcb:= getCallbackFromLCLListBox( ACustomListBox );
if NOT Assigned(lclcb) then
Exit;
if lclcb.getItemStableSelection(AIndex) <> ASelected then begin
cocoaTLV:= getTableViewFromLCLListBox( ACustomListBox );
cocoaTLV.selectOneItemByIndex( AIndex, ASelected );
end;
end;
class procedure TCocoaWSCustomListBox.SetBorderStyle(
@ -2656,7 +2661,7 @@ class procedure TCocoaWSCustomListBox.SetBorderStyle(
var
list: TCocoaTableListView;
begin
list := GetListBox(AWinControl);
list := getTableViewFromLCLListBox( TCustomListBox(AWinControl) );
if not Assigned(list) then Exit;
ScrollViewSetBorderStyle(list.enclosingScrollView, ABorderStyle);
@ -2667,7 +2672,7 @@ class procedure TCocoaWSCustomListBox.SetItemIndex(const ACustomListBox: TCustom
var
list: TCocoaTableListView;
begin
list := GetListBox(ACustomListBox);
list := getTableViewFromLCLListBox(ACustomListBox);
if not Assigned(list) then Exit();
if (AIndex < 0) then
@ -2684,7 +2689,7 @@ var
view: TCocoaTableListView;
column: NSTableColumn;
begin
view := GetListBox(ACustomListBox);
view := getTableViewFromLCLListBox(ACustomListBox);
if not Assigned(view) then Exit;
view.ScrollWidth := AScrollWidth;
column := NSTableColumn(view.tableColumns.objectAtIndex(0));
@ -2704,7 +2709,7 @@ class procedure TCocoaWSCustomListBox.SetSelectionMode(const ACustomListBox: TCu
var
list: TCocoaTableListView;
begin
list := GetListBox(ACustomListBox);
list := getTableViewFromLCLListBox(ACustomListBox);
if not Assigned(list) then Exit();
list.setAllowsMultipleSelection(AMultiSelect);
end;
@ -2713,7 +2718,7 @@ class procedure TCocoaWSCustomListBox.SetStyle(const ACustomListBox: TCustomList
var
view: TCocoaTableListView;
begin
view := GetListBox(ACustomListBox);
view := getTableViewFromLCLListBox(ACustomListBox);
ListBoxSetStyle(view, TCustomListBox(ACustomListBox).Style);
view.setNeedsDisplay_(true);
end;
@ -2722,7 +2727,7 @@ class procedure TCocoaWSCustomListBox.SetTopIndex(const ACustomListBox: TCustomL
var
view: TCocoaTableListView;
begin
view := GetListBox(ACustomListBox);
view := getTableViewFromLCLListBox(ACustomListBox);
if not Assigned(view) then Exit();
view.scrollRowToVisible(NewTopIndex);
end;