From: Vadim Zeitlin Date: Sun, 2 Feb 2003 03:05:41 +0000 (+0000) Subject: indicate whether this is a selection or a deselection in wxCommandEvent generated... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9c9c3d7a8f6c4ee3481674e901d34714ee18915d indicate whether this is a selection or a deselection in wxCommandEvent generated by a multiselection wxListBox git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19060 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index b1ab730b70..e3edea4f3d 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -243,7 +243,9 @@ static void gtk_listitem_deselect_callback( GtkWidget *widget, wxListBox *listbo gtk_listitem_select_cb( widget, listbox, FALSE ); } -static void gtk_listitem_select_cb( GtkWidget *widget, wxListBox *listbox, bool is_selection ) +static void gtk_listitem_select_cb( GtkWidget *widget, + wxListBox *listbox, + bool is_selection ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -255,9 +257,8 @@ static void gtk_listitem_select_cb( GtkWidget *widget, wxListBox *listbox, bool wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); event.SetEventObject( listbox ); -// MSW doesn't do that either -// event.SetExtraLong( (long) is_selection ); - + // indicate whether this is a selection or a deselection + event.SetExtraLong( is_selection ); if ((listbox->GetWindowStyleFlag() & wxLB_SINGLE) != 0) { diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index b1ab730b70..e3edea4f3d 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -243,7 +243,9 @@ static void gtk_listitem_deselect_callback( GtkWidget *widget, wxListBox *listbo gtk_listitem_select_cb( widget, listbox, FALSE ); } -static void gtk_listitem_select_cb( GtkWidget *widget, wxListBox *listbox, bool is_selection ) +static void gtk_listitem_select_cb( GtkWidget *widget, + wxListBox *listbox, + bool is_selection ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -255,9 +257,8 @@ static void gtk_listitem_select_cb( GtkWidget *widget, wxListBox *listbox, bool wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); event.SetEventObject( listbox ); -// MSW doesn't do that either -// event.SetExtraLong( (long) is_selection ); - + // indicate whether this is a selection or a deselection + event.SetExtraLong( is_selection ); if ((listbox->GetWindowStyleFlag() & wxLB_SINGLE) != 0) { diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 59aeac9eea..662b86359f 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -49,7 +49,7 @@ #endif #endif - IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) // ============================================================================ // list box item declaration and implementation @@ -675,20 +675,17 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) wxCommandEvent event(evtType, m_windowId); event.SetEventObject( this ); - wxArrayInt aSelections; - int n, count = GetSelections(aSelections); - if ( count > 0 ) + // retrieve the affected item + int n = SendMessage(GetHwnd(), LB_GETCARETINDEX, 0, 0); + if ( n != LB_ERR ) { - n = aSelections[0]; if ( HasClientObjectData() ) event.SetClientObject( GetClientObject(n) ); else if ( HasClientUntypedData() ) event.SetClientData( GetClientData(n) ); + event.SetString( GetString(n) ); - } - else - { - n = -1; + event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : TRUE ); } event.m_commandInt = n;