virtual bool ButtonClickDidStateChange() = 0;
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
wxWindowMac* m_wxPeer;
bool m_needsFocusRect;
bool m_needsFrame;
+ bool m_shouldSendEvents;
DECLARE_ABSTRACT_CLASS(wxWidgetImpl)
};
{
wxUnusedVar(aNotification);
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
- if ( impl )
+ if ( impl && impl->ShouldSendEvents() )
{
wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
if ( wxpeer ) {
{
wxUnusedVar(notification);
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
- if ( impl )
+ if ( impl && impl->ShouldSendEvents())
{
wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
if ( wxpeer ) {
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
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