Fix wxDataViewColumn::SetSortOrder() under macOS
Don't check if we already sort by the column in SetSortOrder() as this meant the sort order couldn't be changed programmatically at all. Closes #15405.
This commit is contained in:
parent
6c9ced9be2
commit
43c1baf1bd
@ -282,6 +282,7 @@ wxOSX:
|
||||
- Fix selecting RGB bitmaps (with no alpha channel) into wxMemoryDC.
|
||||
- Fix updating radio groups when menu item is inserted/removed from wxMenu.
|
||||
- Allow changing alignment styles after wxTextCtrl creation (Andreas Falkenhahn).
|
||||
- Fix wxDataViewColumn::SetSortOrder() (hartwigw).
|
||||
|
||||
wxQt
|
||||
|
||||
|
@ -3513,23 +3513,27 @@ void wxDataViewColumn::SetSortable(bool sortable)
|
||||
|
||||
void wxDataViewColumn::SetSortOrder(bool ascending)
|
||||
{
|
||||
if (m_ascending != ascending)
|
||||
NSTableColumn* const tableColumn = m_NativeDataPtr->GetNativeColumnPtr();
|
||||
NSTableView* tableView = [tableColumn tableView];
|
||||
|
||||
wxCHECK_RET( tableView, wxS("Column has to be associated with a table view when the sorting order is set") );
|
||||
|
||||
if ( (m_ascending != ascending) || ([tableColumn sortDescriptorPrototype] == nil) )
|
||||
{
|
||||
m_ascending = ascending;
|
||||
if (IsSortKey())
|
||||
{
|
||||
// change sorting order:
|
||||
NSArray* sortDescriptors;
|
||||
NSSortDescriptor* sortDescriptor;
|
||||
NSTableColumn* tableColumn;
|
||||
|
||||
tableColumn = m_NativeDataPtr->GetNativeColumnPtr();
|
||||
sortDescriptor = [[NSSortDescriptor alloc] initWithKey:[[tableColumn sortDescriptorPrototype] key] ascending:m_ascending];
|
||||
sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
|
||||
[tableColumn setSortDescriptorPrototype:sortDescriptor];
|
||||
[[tableColumn tableView] setSortDescriptors:sortDescriptors];
|
||||
[sortDescriptor release];
|
||||
}
|
||||
// change sorting order for the native implementation (this will
|
||||
// trigger a call to outlineView:sortDescriptorsDidChange: where the
|
||||
// wxWidget's sort descriptors are going to be set):
|
||||
NSSortDescriptor* const
|
||||
sortDescriptor = [[NSSortDescriptor alloc]
|
||||
initWithKey:[NSString stringWithFormat:@"%ld",(long)[tableView columnWithIdentifier:[tableColumn identifier]]]
|
||||
ascending:m_ascending];
|
||||
|
||||
NSArray* sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
|
||||
[tableColumn setSortDescriptorPrototype:sortDescriptor];
|
||||
[tableView setSortDescriptors:sortDescriptors];
|
||||
[sortDescriptor release];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user