Move wxListBox selection event generation to wxListBox itself
This allows to avoid making DoChangeSingleSelection() and CalcAndSendEvent() public. No real changes, this is just a refactoring.
This commit is contained in:
@@ -126,10 +126,8 @@ public:
|
|||||||
|
|
||||||
virtual void HandleLineEvent( unsigned int n, bool doubleClick );
|
virtual void HandleLineEvent( unsigned int n, bool doubleClick );
|
||||||
|
|
||||||
// These are called by wxNSTableView
|
// This is called by wxNSTableView
|
||||||
using wxListBoxBase::DoChangeSingleSelection;
|
void MacHandleSelectionChange(int row);
|
||||||
using wxListBoxBase::CalcAndSendEvent;
|
|
||||||
int GetOldSelection() const { return m_oldSelections.empty() ? wxNOT_FOUND : m_oldSelections[0]; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// callback for derived classes which may have to insert additional data
|
// callback for derived classes which may have to insert additional data
|
||||||
|
@@ -301,29 +301,7 @@ protected:
|
|||||||
wxListBox* const list = wxDynamicCast(impl->GetWXPeer(), wxListBox);
|
wxListBox* const list = wxDynamicCast(impl->GetWXPeer(), wxListBox);
|
||||||
wxCHECK_RET( list != NULL , "Associated control should be a wxListBox" );
|
wxCHECK_RET( list != NULL , "Associated control should be a wxListBox" );
|
||||||
|
|
||||||
// Correct notification events for multiselection list, like in Carbon version
|
list->MacHandleSelectionChange(row);
|
||||||
if (list->HasMultipleSelection() && !list->MacGetBlockEvents())
|
|
||||||
{
|
|
||||||
list->CalcAndSendEvent();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !list->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) list->GetCount()))
|
|
||||||
{
|
|
||||||
int oldsel = list->GetOldSelection();
|
|
||||||
if (oldsel >= 0)
|
|
||||||
list->SetSelection(oldsel);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ( !list->DoChangeSingleSelection(row) )
|
|
||||||
return ;
|
|
||||||
list->HandleLineEvent( row, false );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFont:(NSFont *)aFont
|
- (void)setFont:(NSFont *)aFont
|
||||||
|
@@ -420,6 +420,36 @@ void wxListBox::HandleLineEvent( unsigned int n, bool doubleClick )
|
|||||||
HandleWindowEvent(event);
|
HandleWindowEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxListBox::MacHandleSelectionChange(int row)
|
||||||
|
{
|
||||||
|
// Correct notification events for multiselection list, like in Carbon version
|
||||||
|
if ( HasMultipleSelection() && !MacGetBlockEvents() )
|
||||||
|
{
|
||||||
|
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()))
|
||||||
|
{
|
||||||
|
if ( !m_oldSelections.empty() )
|
||||||
|
{
|
||||||
|
const int oldsel = m_oldSelections[0];
|
||||||
|
if (oldsel >= 0)
|
||||||
|
SetSelection(oldsel);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( !DoChangeSingleSelection(row) )
|
||||||
|
return ;
|
||||||
|
HandleLineEvent( row, false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// common list cell value operations
|
// common list cell value operations
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user