Disable sending of events by OS X Combobox during programmatic changes.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63519 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -277,6 +277,12 @@ public :
|
||||
|
||||
virtual void InstallEventHandler( WXWidget control = NULL ) = 0;
|
||||
|
||||
// Mechanism used to keep track of whether a change should send an event
|
||||
// Do SendEvents(false) when starting actions that would trigger programmatic events
|
||||
// and SendEvents(true) at the end of the block.
|
||||
virtual void SendEvents(bool shouldSendEvents) { m_shouldSendEvents = shouldSendEvents; }
|
||||
virtual bool ShouldSendEvents() { return m_shouldSendEvents; }
|
||||
|
||||
// static methods for associating native controls and their implementations
|
||||
|
||||
static wxWidgetImpl*
|
||||
@@ -490,6 +496,7 @@ protected :
|
||||
wxWindowMac* m_wxPeer;
|
||||
bool m_needsFocusRect;
|
||||
bool m_needsFrame;
|
||||
bool m_shouldSendEvents;
|
||||
|
||||
DECLARE_ABSTRACT_CLASS(wxWidgetImpl)
|
||||
};
|
||||
|
@@ -46,7 +46,7 @@
|
||||
{
|
||||
wxUnusedVar(aNotification);
|
||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||
if ( impl )
|
||||
if ( impl && impl->ShouldSendEvents() )
|
||||
{
|
||||
wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
|
||||
if ( wxpeer ) {
|
||||
@@ -62,7 +62,7 @@
|
||||
{
|
||||
wxUnusedVar(notification);
|
||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||
if ( impl )
|
||||
if ( impl && impl->ShouldSendEvents())
|
||||
{
|
||||
wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
|
||||
if ( wxpeer ) {
|
||||
@@ -95,7 +95,9 @@ int wxNSComboBoxControl::GetSelectedItem() const
|
||||
void wxNSComboBoxControl::SetSelectedItem(int item)
|
||||
{
|
||||
wxASSERT_MSG(item >= 0 && item < [m_comboBox numberOfItems], "Inavlid item index.");
|
||||
SendEvents(false);
|
||||
[m_comboBox selectItemAtIndex: item];
|
||||
SendEvents(true);
|
||||
}
|
||||
|
||||
int wxNSComboBoxControl::GetNumberOfItems() const
|
||||
@@ -110,12 +112,16 @@ void wxNSComboBoxControl::InsertItem(int pos, const wxString& item)
|
||||
|
||||
void wxNSComboBoxControl::RemoveItem(int pos)
|
||||
{
|
||||
SendEvents(false);
|
||||
[m_comboBox removeItemAtIndex:pos];
|
||||
SendEvents(true);
|
||||
}
|
||||
|
||||
void wxNSComboBoxControl::Clear()
|
||||
{
|
||||
SendEvents(false);
|
||||
[m_comboBox removeAllItems];
|
||||
SendEvents(true);
|
||||
}
|
||||
|
||||
wxString wxNSComboBoxControl::GetStringAtIndex(int pos) const
|
||||
|
@@ -2464,6 +2464,7 @@ wxWidgetImpl::wxWidgetImpl( wxWindowMac* peer , bool isRootControl )
|
||||
Init();
|
||||
m_isRootControl = isRootControl;
|
||||
m_wxPeer = peer;
|
||||
m_shouldSendEvents = true;
|
||||
}
|
||||
|
||||
wxWidgetImpl::wxWidgetImpl()
|
||||
|
Reference in New Issue
Block a user