X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e976429dfade9fe445d1d5abf630e9458d51abbe..318b0bd54495cc47bc6b678d3941026ea1a0c20b:/src/gtk/combobox.cpp diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 3e3429f1fa..e3feabd011 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -116,6 +116,11 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, m_widget = gtk_combo_box_entry_new_text(); + // Set it up to trigger default item on enter key press + GtkWidget *widget = gtk_bin_get_child(GTK_BIN(m_widget)); + gtk_entry_set_activates_default(GTK_ENTRY(widget), + !HasFlag(wxTE_PROCESS_ENTER)); + if (HasFlag(wxBORDER_NONE)) { // Doesn't seem to work @@ -382,17 +387,6 @@ void wxComboBox::OnChar( wxKeyEvent &event ) return; } } - - // On enter key press, we must give a signal to default control, - // Otherwise, nothing happens when pressing Enter from inside a - // combo box in a dialog. - wxWindow *top_frame = wxGetTopLevelParent(this); - if( top_frame && GTK_IS_WINDOW(top_frame->m_widget) ) - { - GtkWindow *window = GTK_WINDOW(top_frame->m_widget); - if ( window->default_widget ) - gtk_widget_activate( window->default_widget ); - } break; } @@ -431,25 +425,27 @@ GdkWindow *wxComboBox::GTKGetWindow(wxArrayGdkWindows& windows) const wxSize wxComboBox::DoGetBestSize() const { + // strangely, this returns a width of 188 pixels from GTK+ (?) wxSize ret( wxControl::DoGetBestSize() ); // we know better our horizontal extent: it depends on the longest string // in the combobox if ( m_widget ) { + ret.x = 60; // start with something "sensible" int width; unsigned int count = GetCount(); for ( unsigned int n = 0; n < count; n++ ) { GetTextExtent(GetString(n), &width, NULL, NULL, NULL ); - if ( width > ret.x ) - ret.x = width; + if ( width + 40 > ret.x ) // 40 for drop down arrow and space around text + ret.x = width + 40; } } // empty combobox should have some reasonable default size too - if ( ret.x < 100 ) - ret.x = 100; + if ((GetCount() == 0) && (ret.x < 80)) + ret.x = 80; CacheBestSize(ret); return ret; @@ -493,10 +489,7 @@ void wxComboBox::OnRedo(wxCommandEvent& WXUNUSED(event)) void wxComboBox::OnDelete(wxCommandEvent& WXUNUSED(event)) { - long from, to; - GetSelection(& from, & to); - if (from != -1 && to != -1) - Remove(from, to); + RemoveSelection(); } void wxComboBox::OnSelectAll(wxCommandEvent& WXUNUSED(event))