mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-12 02:18:44 +02:00
Cocoa/ListView: fix the issue that checkBox may be reset after sorting
This commit is contained in:
parent
210f0fac8a
commit
9aee14430e
@ -1171,20 +1171,8 @@ end;
|
||||
|
||||
procedure TCocoaWSListView_CollectionViewHandler.ItemSetChecked(
|
||||
const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean);
|
||||
var
|
||||
lclcb: TLCLListViewCallback;
|
||||
begin
|
||||
lclcb:= getCallback;
|
||||
if NOT Assigned(lclcb) then
|
||||
Exit;
|
||||
|
||||
if AChecked and not lclcb.checkedIdx.containsIndex(AIndex) then begin
|
||||
lclcb.checkedIdx.addIndex(AIndex);
|
||||
_collectionView.reloadData;
|
||||
end else if not AChecked and lclcb.checkedIdx.containsIndex(AIndex) then begin
|
||||
lclcb.checkedIdx.removeIndex(AIndex);
|
||||
_collectionView.reloadData;
|
||||
end;
|
||||
_collectionView.reloadData;
|
||||
end;
|
||||
|
||||
procedure TCocoaWSListView_CollectionViewHandler.ItemSetImage(
|
||||
|
@ -1792,20 +1792,8 @@ end;
|
||||
|
||||
procedure TCocoaWSListView_TableViewHandler.ItemSetChecked(
|
||||
const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean);
|
||||
var
|
||||
lclcb: TLCLListViewCallback;
|
||||
begin
|
||||
lclcb:= getCallback;
|
||||
if NOT Assigned(lclcb) then
|
||||
Exit;
|
||||
|
||||
if AChecked and not lclcb.checkedIdx.containsIndex(AIndex) then begin
|
||||
lclcb.checkedIdx.addIndex(AIndex);
|
||||
_tableView.reloadDataForRow_column(AIndex, 0);
|
||||
end else if not AChecked and lclcb.checkedIdx.containsIndex(AIndex) then begin
|
||||
lclcb.checkedIdx.removeIndex(AIndex);
|
||||
_tableView.reloadDataForRow_column(AIndex, 0);
|
||||
end;
|
||||
_tableView.reloadDataForRow_column(AIndex, 0);
|
||||
end;
|
||||
|
||||
procedure TCocoaWSListView_TableViewHandler.ItemSetImage(
|
||||
|
@ -17,6 +17,8 @@ type
|
||||
{ TCocoaWSCustomListView }
|
||||
|
||||
TCocoaWSCustomListView = class(TWSCustomListView)
|
||||
private
|
||||
class var _settingLCLDirectly: Boolean;
|
||||
private
|
||||
class function getWSHandler( const lclListView: TCustomListView ):
|
||||
TCocoaWSListViewHandler;
|
||||
@ -365,10 +367,34 @@ class procedure TCocoaWSCustomListView.ItemSetChecked(
|
||||
const AChecked: Boolean);
|
||||
var
|
||||
WSHandler: TCocoaWSListViewHandler;
|
||||
lclcb: TLCLListViewCallback;
|
||||
cocoaListView: TCocoaListView;
|
||||
needsUpdate: Boolean = False;
|
||||
begin
|
||||
WSHandler:= getWSHandler( ALV );
|
||||
if Assigned(WSHandler) then
|
||||
WSHandler.ItemSetChecked( AIndex, AItem, AChecked );
|
||||
if _settingLCLDirectly then
|
||||
Exit;
|
||||
|
||||
lclcb:= self.getCallback( ALV );
|
||||
if NOT Assigned(lclcb) then
|
||||
Exit;
|
||||
|
||||
if AChecked and not lclcb.checkedIdx.containsIndex(AIndex) then begin
|
||||
lclcb.checkedIdx.addIndex(AIndex);
|
||||
needsUpdate:= True;
|
||||
end else if not AChecked and lclcb.checkedIdx.containsIndex(AIndex) then begin
|
||||
lclcb.checkedIdx.removeIndex(AIndex);
|
||||
needsUpdate:= True;
|
||||
end;
|
||||
|
||||
if needsUpdate then begin
|
||||
WSHandler:= getWSHandler( ALV );
|
||||
if Assigned(WSHandler) then
|
||||
WSHandler.ItemSetChecked( AIndex, AItem, AChecked );
|
||||
end;
|
||||
|
||||
_settingLCLDirectly:= True;
|
||||
AItem.Checked:= AChecked;
|
||||
_settingLCLDirectly:= False;
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomListView.ItemSetImage(const ALV: TCustomListView;
|
||||
|
Loading…
Reference in New Issue
Block a user