mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 20:20:28 +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(
|
procedure TCocoaWSListView_CollectionViewHandler.ItemSetChecked(
|
||||||
const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean);
|
const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean);
|
||||||
var
|
|
||||||
lclcb: TLCLListViewCallback;
|
|
||||||
begin
|
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;
|
_collectionView.reloadData;
|
||||||
end else if not AChecked and lclcb.checkedIdx.containsIndex(AIndex) then begin
|
|
||||||
lclcb.checkedIdx.removeIndex(AIndex);
|
|
||||||
_collectionView.reloadData;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaWSListView_CollectionViewHandler.ItemSetImage(
|
procedure TCocoaWSListView_CollectionViewHandler.ItemSetImage(
|
||||||
|
@ -1792,20 +1792,8 @@ end;
|
|||||||
|
|
||||||
procedure TCocoaWSListView_TableViewHandler.ItemSetChecked(
|
procedure TCocoaWSListView_TableViewHandler.ItemSetChecked(
|
||||||
const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean);
|
const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean);
|
||||||
var
|
|
||||||
lclcb: TLCLListViewCallback;
|
|
||||||
begin
|
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);
|
_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;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaWSListView_TableViewHandler.ItemSetImage(
|
procedure TCocoaWSListView_TableViewHandler.ItemSetImage(
|
||||||
|
@ -17,6 +17,8 @@ type
|
|||||||
{ TCocoaWSCustomListView }
|
{ TCocoaWSCustomListView }
|
||||||
|
|
||||||
TCocoaWSCustomListView = class(TWSCustomListView)
|
TCocoaWSCustomListView = class(TWSCustomListView)
|
||||||
|
private
|
||||||
|
class var _settingLCLDirectly: Boolean;
|
||||||
private
|
private
|
||||||
class function getWSHandler( const lclListView: TCustomListView ):
|
class function getWSHandler( const lclListView: TCustomListView ):
|
||||||
TCocoaWSListViewHandler;
|
TCocoaWSListViewHandler;
|
||||||
@ -365,12 +367,36 @@ class procedure TCocoaWSCustomListView.ItemSetChecked(
|
|||||||
const AChecked: Boolean);
|
const AChecked: Boolean);
|
||||||
var
|
var
|
||||||
WSHandler: TCocoaWSListViewHandler;
|
WSHandler: TCocoaWSListViewHandler;
|
||||||
|
lclcb: TLCLListViewCallback;
|
||||||
|
cocoaListView: TCocoaListView;
|
||||||
|
needsUpdate: Boolean = False;
|
||||||
begin
|
begin
|
||||||
|
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 );
|
WSHandler:= getWSHandler( ALV );
|
||||||
if Assigned(WSHandler) then
|
if Assigned(WSHandler) then
|
||||||
WSHandler.ItemSetChecked( AIndex, AItem, AChecked );
|
WSHandler.ItemSetChecked( AIndex, AItem, AChecked );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
_settingLCLDirectly:= True;
|
||||||
|
AItem.Checked:= AChecked;
|
||||||
|
_settingLCLDirectly:= False;
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TCocoaWSCustomListView.ItemSetImage(const ALV: TCustomListView;
|
class procedure TCocoaWSCustomListView.ItemSetImage(const ALV: TCustomListView;
|
||||||
const AIndex: Integer; const AItem: TListItem; const ASubIndex,
|
const AIndex: Integer; const AItem: TListItem; const ASubIndex,
|
||||||
AImageIndex: Integer);
|
AImageIndex: Integer);
|
||||||
|
Loading…
Reference in New Issue
Block a user