X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/12f316268643e7a66b142804c3b9b0aec4af5801..7af68c666bda771e37812ca37f0c6cc1741fa3ec:/src/mac/combobox.cpp diff --git a/src/mac/combobox.cpp b/src/mac/combobox.cpp index 718fe840d6..e67e1d9601 100644 --- a/src/mac/combobox.cpp +++ b/src/mac/combobox.cpp @@ -6,7 +6,7 @@ // Created: ??/??/98 // RCS-ID: $Id$ // Copyright: (c) AUTHOR -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -60,8 +60,9 @@ protected: void OnTextChange( wxCommandEvent& event ) { wxString s = GetValue(); - - m_cb->DelegateTextChanged( s ); + + if (!s.IsEmpty()) + m_cb->DelegateTextChanged( s ); event.Skip(); } @@ -103,16 +104,19 @@ BEGIN_EVENT_TABLE(wxComboBoxChoice, wxChoice) EVT_CHOICE(-1, wxComboBoxChoice::OnChoice) END_EVENT_TABLE() - - - wxComboBox::~wxComboBox() { - // delete the controls now, don't leave them alive even though they woudl + // delete the controls now, don't leave them alive even though they would // still be eventually deleted by our parent - but it will be too late, the // user code expects them to be gone now - delete m_text; - delete m_choice; + if (m_text != NULL) { + delete m_text; + m_text = NULL; + } + if (m_choice != NULL) { + delete m_choice; + m_choice = NULL; + } } @@ -191,6 +195,11 @@ bool wxComboBox::Show(bool show) return TRUE; } + void wxComboBox::SetFocus() + { + m_text->SetFocus(); + } + void wxComboBox::DelegateTextChanged( const wxString& value ) { } @@ -206,8 +215,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, - int n, const wxString choices[], - long style, + int n, const wxString choices[], + long style, const wxValidator& validator, const wxString& name) { @@ -239,7 +248,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, DoSetSize(pos.x, pos.y, csize.x, csize.y); for ( int i = 0 ; i < n ; i++ ) { - m_choice->DoAppend( choices[ i ] ); + m_choice->DoAppend( choices[ i ] ); } // have to disable this window to avoid interfering it with message @@ -361,7 +370,11 @@ void wxComboBox::SetSelection(long from, long to) void wxComboBox::Append(const wxString& item) { - m_choice->DoAppend( item ); + // I am not sure what other ports do, + // but wxMac chokes on empty entries. + + if (!item.IsEmpty()) + m_choice->DoAppend( item ); } void wxComboBox::Delete(int n) @@ -423,7 +436,7 @@ bool wxComboBox::SetStringSelection(const wxString& sel) void wxComboBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId ); - event.SetInt(GetSelection()); + event.SetInt(GetSelection()); event.SetEventObject(this); event.SetString(GetStringSelection()); ProcessCommand(event);