From c3728eafab153f3f224734a4a7534a8122520968 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 20 Oct 2000 15:04:37 +0000 Subject: [PATCH] Set wxLB_SINGLE style if no style is set. Eat presses so that no item gets unselected in single mode. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@8601 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/listbox.cpp | 18 +++++++++++++++++- src/gtk1/listbox.cpp | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 563385ef1f..9cb860b8aa 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -195,6 +195,12 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis ret = listbox->GetEventHandler()->ProcessEvent( new_event ); } + if ((gdk_event->keyval == GDK_Return) && listbox->HasFlag(wxLB_SINGLE) && (!ret)) + { + // eat return in single mode + ret = TRUE; + } + #if wxUSE_CHECKLISTBOX if ((gdk_event->keyval == ' ') && (listbox->m_hasCheckBoxes) && (!ret)) { @@ -311,11 +317,21 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, m_list = GTK_LIST( gtk_list_new() ); - GtkSelectionMode mode = GTK_SELECTION_BROWSE; + GtkSelectionMode mode; if (style & wxLB_MULTIPLE) + { mode = GTK_SELECTION_MULTIPLE; + } else if (style & wxLB_EXTENDED) + { mode = GTK_SELECTION_EXTENDED; + } + else + { + // if style was 0 set single mode + m_windowStyle |= wxLB_SINGLE; + mode = GTK_SELECTION_BROWSE; + } gtk_list_set_selection_mode( GTK_LIST(m_list), mode ); diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index 563385ef1f..9cb860b8aa 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -195,6 +195,12 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis ret = listbox->GetEventHandler()->ProcessEvent( new_event ); } + if ((gdk_event->keyval == GDK_Return) && listbox->HasFlag(wxLB_SINGLE) && (!ret)) + { + // eat return in single mode + ret = TRUE; + } + #if wxUSE_CHECKLISTBOX if ((gdk_event->keyval == ' ') && (listbox->m_hasCheckBoxes) && (!ret)) { @@ -311,11 +317,21 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, m_list = GTK_LIST( gtk_list_new() ); - GtkSelectionMode mode = GTK_SELECTION_BROWSE; + GtkSelectionMode mode; if (style & wxLB_MULTIPLE) + { mode = GTK_SELECTION_MULTIPLE; + } else if (style & wxLB_EXTENDED) + { mode = GTK_SELECTION_EXTENDED; + } + else + { + // if style was 0 set single mode + m_windowStyle |= wxLB_SINGLE; + mode = GTK_SELECTION_BROWSE; + } gtk_list_set_selection_mode( GTK_LIST(m_list), mode );