Merge branch 'mac-lbox-sel-events'
Fix Mac wxListBox selection behaviour and events. See https://github.com/wxWidgets/wxWidgets/pull/847
This commit is contained in:
@@ -122,9 +122,11 @@ public:
|
|||||||
|
|
||||||
wxListWidgetImpl* GetListPeer() const;
|
wxListWidgetImpl* GetListPeer() const;
|
||||||
|
|
||||||
bool MacGetBlockEvents() const { return m_blockEvents; }
|
|
||||||
|
|
||||||
virtual void HandleLineEvent( unsigned int n, bool doubleClick );
|
virtual void HandleLineEvent( unsigned int n, bool doubleClick );
|
||||||
|
|
||||||
|
// This is called by wxNSTableView
|
||||||
|
void MacHandleSelectionChange(int row);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// callback for derived classes which may have to insert additional data
|
// callback for derived classes which may have to insert additional data
|
||||||
// at a certain line - which cannot be predetermined for sorted list data
|
// at a certain line - which cannot be predetermined for sorted list data
|
||||||
|
@@ -297,23 +297,11 @@ protected:
|
|||||||
|
|
||||||
int row = [self selectedRow];
|
int row = [self selectedRow];
|
||||||
|
|
||||||
if (row == -1)
|
|
||||||
{
|
|
||||||
// no row selected
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
wxListBox *list = static_cast<wxListBox*> ( impl->GetWXPeer());
|
wxListBox* const list = wxDynamicCast(impl->GetWXPeer(), wxListBox);
|
||||||
wxCHECK_RET( list != NULL , wxT("Listbox expected"));
|
wxCHECK_RET( list != NULL , "Associated control should be a wxListBox" );
|
||||||
|
|
||||||
if ((row < 0) || (row > (int) list->GetCount())) // OS X can select an item below the last item
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( !list->MacGetBlockEvents() )
|
|
||||||
list->HandleLineEvent( row, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
list->MacHandleSelectionChange(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFont:(NSFont *)aFont
|
- (void)setFont:(NSFont *)aFont
|
||||||
|
@@ -420,6 +420,40 @@ void wxListBox::HandleLineEvent( unsigned int n, bool doubleClick )
|
|||||||
HandleWindowEvent(event);
|
HandleWindowEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxListBox::MacHandleSelectionChange(int row)
|
||||||
|
{
|
||||||
|
if ( m_blockEvents )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Correct notification events for multiselection list.
|
||||||
|
if ( HasMultipleSelection() )
|
||||||
|
{
|
||||||
|
CalcAndSendEvent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// OS X can select an item below the last item. In that case keep the old
|
||||||
|
// selection because in wxWidgets API there is no notification event for
|
||||||
|
// removing the selection from a single-selection list box.
|
||||||
|
//
|
||||||
|
// Otherwise call DoChangeSingleSelection so GetOldSelection() will return
|
||||||
|
// the correct value if row < 0 later.
|
||||||
|
const int count = static_cast<int>(GetCount());
|
||||||
|
if ( row < 0 || row >= count )
|
||||||
|
{
|
||||||
|
if ( !m_oldSelections.empty() )
|
||||||
|
{
|
||||||
|
const int oldsel = m_oldSelections[0];
|
||||||
|
if ( oldsel >= 0 && oldsel < count )
|
||||||
|
SetSelection(oldsel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( DoChangeSingleSelection(row) )
|
||||||
|
{
|
||||||
|
HandleLineEvent( row, false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// common list cell value operations
|
// common list cell value operations
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user