mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 08:19:41 +02:00
Cocoa: Fixed the issue of calling reloadData in NSTableView triggering OnChange
TListView / TListBox / TCheckListBox
This commit is contained in:
parent
2e21040755
commit
253c6b1be6
@ -80,6 +80,7 @@ type
|
||||
iconSize: NSSize;
|
||||
callback: TLCLListControlCallback;
|
||||
selectingByProgram: Boolean;
|
||||
dontSendOnChangeMessage: Boolean;
|
||||
readOnly: Boolean;
|
||||
isOwnerDraw : Boolean;
|
||||
isDynamicRowHeight: Boolean;
|
||||
@ -672,8 +673,10 @@ begin
|
||||
if NOT Assigned(self.callback) then
|
||||
Exit;
|
||||
|
||||
self.dontSendOnChangeMessage:= True;
|
||||
selection:= self.callback.selectionIndexSet;
|
||||
self.selectRowIndexesByProgram( selection );
|
||||
self.dontSendOnChangeMessage:= False;
|
||||
end;
|
||||
|
||||
procedure TCocoaTableListView.reloadData;
|
||||
@ -685,6 +688,12 @@ begin
|
||||
|
||||
inherited reloadData;
|
||||
_processor.onReloadData( self );
|
||||
|
||||
// 1. the first step is here
|
||||
// synchronously restore the selection immediately after calling reloadData()
|
||||
// 2. the second step is elsewhere
|
||||
// the selection will be restored asynchronously after reloadData actually takes effect.
|
||||
self.restoreFromStableSelection;
|
||||
end;
|
||||
|
||||
procedure TCocoaTableListView.reloadDataForRow_column(ARow, ACol: NSInteger);
|
||||
@ -2030,6 +2039,9 @@ begin
|
||||
selectionIndexSet.addIndexes( tv.selectedRowIndexes );
|
||||
end;
|
||||
|
||||
if cocoaTLV.dontSendOnChangeMessage then
|
||||
Exit;
|
||||
|
||||
NewSel := cocoaTLV.selectedRow();
|
||||
sendSelectionChangedMsgToLCL( lclListView, NewSel, ad, rm );
|
||||
end;
|
||||
|
@ -2500,6 +2500,9 @@ begin
|
||||
lclcb.selectionIndexSet.addIndexes( tv.selectedRowIndexes );
|
||||
end;
|
||||
|
||||
if cocoaTLV.dontSendOnChangeMessage then
|
||||
Exit;
|
||||
|
||||
// do not notify about selection changes while clearing
|
||||
if Assigned(lclcb.strings) and (lclcb.strings.isClearing) then Exit;
|
||||
SendSimpleMessage(lclListBox, LM_SELCHANGE);
|
||||
|
Loading…
Reference in New Issue
Block a user