X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1d5a4d441bb424320db2644b30c19b7c5bb0c234..593354ca47abaae8a434f99642acc57f7834f77b:/src/gtk/choice.cpp diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index b63c3c68bc..af2b1092fd 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -62,7 +62,7 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice * else if ( choice->HasClientUntypedData() ) event.SetClientData( choice->GetClientData(n) ); - choice->GetEventHandler()->ProcessEvent(event); + choice->HandleWindowEvent(event); } } @@ -163,6 +163,12 @@ int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items, m_selection_hack += count; } + // We must set the selection so that it can be read back even if + // the user has not modified it since GTK+ will then select the + // first item so well return 0. + if ((count > 0) && (m_selection_hack==wxNOT_FOUND)) + m_selection_hack = 0; + return pos - 1; } @@ -216,8 +222,8 @@ void wxChoice::DoDeleteOneItem(unsigned int n) wxArrayString items; wxArrayPtrVoid itemsData; - items.Alloc(count); - itemsData.Alloc(count); + items.Alloc(count - 1); + itemsData.Alloc(count - 1); for ( unsigned i = 0; i < count; i++ ) { if ( i != n ) @@ -229,11 +235,15 @@ void wxChoice::DoDeleteOneItem(unsigned int n) wxChoice::DoClear(); - void ** const data = &itemsData[0]; - if ( HasClientObjectData() ) - Append(items, wx_reinterpret_cast(wxClientData **, data)); - else - Append(items, data); + if ( count > 1 ) + { + void ** const data = &itemsData[0]; + if ( HasClientObjectData() ) + Append(items, wx_reinterpret_cast(wxClientData **, data)); + else + Append(items, data); + } + //else: the control is now empty, nothing to append } int wxChoice::FindString( const wxString &string, bool bCase ) const