Remove wxListBox::MacGetBlockEvents()

Just test m_blockEvents directly, there doesn't seem to be any gain in
using an accessor here.

Also test it only once instead of doing it twice in
MacHandleSelectionChange().
This commit is contained in:
Vadim Zeitlin
2018-06-30 23:14:36 +02:00
parent dde6f662fc
commit eadcd93bf9
2 changed files with 16 additions and 18 deletions

View File

@@ -122,8 +122,6 @@ public:
wxListWidgetImpl* GetListPeer() const;
bool MacGetBlockEvents() const { return m_blockEvents; }
virtual void HandleLineEvent( unsigned int n, bool doubleClick );
// This is called by wxNSTableView

View File

@@ -422,32 +422,32 @@ void wxListBox::HandleLineEvent( unsigned int n, bool doubleClick )
void wxListBox::MacHandleSelectionChange(int row)
{
if ( m_blockEvents )
return;
// Correct notification events for multiselection list, like in Carbon version
if ( HasMultipleSelection() && !MacGetBlockEvents() )
if ( HasMultipleSelection() )
{
CalcAndSendEvent();
return;
}
if ( !MacGetBlockEvents() )
// 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.
if ((row < 0) || (row > (int) GetCount()))
{
// 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.
if ((row < 0) || (row > (int) GetCount()))
if ( !m_oldSelections.empty() )
{
if ( !m_oldSelections.empty() )
{
const int oldsel = m_oldSelections[0];
if (oldsel >= 0)
SetSelection(oldsel);
}
return;
const int oldsel = m_oldSelections[0];
if (oldsel >= 0)
SetSelection(oldsel);
}
if ( !DoChangeSingleSelection(row) )
return ;
HandleLineEvent( row, false );
return;
}
if ( !DoChangeSingleSelection(row) )
return ;
HandleLineEvent( row, false );
}
//