mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 10:19:22 +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;
|
iconSize: NSSize;
|
||||||
callback: TLCLListControlCallback;
|
callback: TLCLListControlCallback;
|
||||||
selectingByProgram: Boolean;
|
selectingByProgram: Boolean;
|
||||||
|
dontSendOnChangeMessage: Boolean;
|
||||||
readOnly: Boolean;
|
readOnly: Boolean;
|
||||||
isOwnerDraw : Boolean;
|
isOwnerDraw : Boolean;
|
||||||
isDynamicRowHeight: Boolean;
|
isDynamicRowHeight: Boolean;
|
||||||
@ -672,8 +673,10 @@ begin
|
|||||||
if NOT Assigned(self.callback) then
|
if NOT Assigned(self.callback) then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
|
self.dontSendOnChangeMessage:= True;
|
||||||
selection:= self.callback.selectionIndexSet;
|
selection:= self.callback.selectionIndexSet;
|
||||||
self.selectRowIndexesByProgram( selection );
|
self.selectRowIndexesByProgram( selection );
|
||||||
|
self.dontSendOnChangeMessage:= False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaTableListView.reloadData;
|
procedure TCocoaTableListView.reloadData;
|
||||||
@ -685,6 +688,12 @@ begin
|
|||||||
|
|
||||||
inherited reloadData;
|
inherited reloadData;
|
||||||
_processor.onReloadData( self );
|
_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;
|
end;
|
||||||
|
|
||||||
procedure TCocoaTableListView.reloadDataForRow_column(ARow, ACol: NSInteger);
|
procedure TCocoaTableListView.reloadDataForRow_column(ARow, ACol: NSInteger);
|
||||||
@ -2030,6 +2039,9 @@ begin
|
|||||||
selectionIndexSet.addIndexes( tv.selectedRowIndexes );
|
selectionIndexSet.addIndexes( tv.selectedRowIndexes );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if cocoaTLV.dontSendOnChangeMessage then
|
||||||
|
Exit;
|
||||||
|
|
||||||
NewSel := cocoaTLV.selectedRow();
|
NewSel := cocoaTLV.selectedRow();
|
||||||
sendSelectionChangedMsgToLCL( lclListView, NewSel, ad, rm );
|
sendSelectionChangedMsgToLCL( lclListView, NewSel, ad, rm );
|
||||||
end;
|
end;
|
||||||
|
@ -2500,6 +2500,9 @@ begin
|
|||||||
lclcb.selectionIndexSet.addIndexes( tv.selectedRowIndexes );
|
lclcb.selectionIndexSet.addIndexes( tv.selectedRowIndexes );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if cocoaTLV.dontSendOnChangeMessage then
|
||||||
|
Exit;
|
||||||
|
|
||||||
// do not notify about selection changes while clearing
|
// do not notify about selection changes while clearing
|
||||||
if Assigned(lclcb.strings) and (lclcb.strings.isClearing) then Exit;
|
if Assigned(lclcb.strings) and (lclcb.strings.isClearing) then Exit;
|
||||||
SendSimpleMessage(lclListBox, LM_SELCHANGE);
|
SendSimpleMessage(lclListBox, LM_SELCHANGE);
|
||||||
|
Loading…
Reference in New Issue
Block a user