add combobox drop down/close up events (closes #10587)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59603 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-03-18 10:42:58 +00:00
parent 099c2c7d7f
commit 8933fbc62e
7 changed files with 67 additions and 1 deletions

View File

@@ -403,6 +403,7 @@ All (GUI):
- Also added wxCANCEL_DEFAULT to wxMessageDialog. - Also added wxCANCEL_DEFAULT to wxMessageDialog.
- Allow copying text in the log dialogs. - Allow copying text in the log dialogs.
- Added multisample (anti-aliasing) support to wxGLCanvas (Olivier Playez). - Added multisample (anti-aliasing) support to wxGLCanvas (Olivier Playez).
- Added wxEVT_COMMAND_COMBOBOX_DROPDOWN/CLOSEUP events (Igor Korot).
- Added wxCAL_SHOW_WEEK_NUMBERS wxCalendarCtrl style (S<>ren Meyer-Eppler). - Added wxCAL_SHOW_WEEK_NUMBERS wxCalendarCtrl style (S<>ren Meyer-Eppler).
- Initialize wx{Client,Paint,Window}DC with fonts/colours of its window. - Initialize wx{Client,Paint,Window}DC with fonts/colours of its window.
- Added wxNativeContainerWindow to allow embedding wx into native windows. - Added wxNativeContainerWindow to allow embedding wx into native windows.

View File

@@ -596,6 +596,8 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCo
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_RCLICKED, wxCommandEvent); wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_RCLICKED, wxCommandEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, wxCommandEvent); wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, wxCommandEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_ENTER, wxCommandEvent); wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOL_ENTER, wxCommandEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COMBOBOX_DROPDOWN, wxCommandEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COMBOBOX_CLOSEUP, wxCommandEvent);
// Thread events // Thread events
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_THREAD, wxThreadEvent); wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_THREAD, wxThreadEvent);
@@ -3749,6 +3751,8 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent&
#define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_COMMAND_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func)) #define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_COMMAND_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func))
#define EVT_TOOL_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_ENTER, winid, wxCommandEventHandler(func)) #define EVT_TOOL_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_ENTER, winid, wxCommandEventHandler(func))
#define EVT_CHECKLISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, winid, wxCommandEventHandler(func)) #define EVT_CHECKLISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, winid, wxCommandEventHandler(func))
#define EVT_COMBOBOX_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_COMBOBOX_DROPDOWN, winid, wxCommandEventHandler(func))
#define EVT_COMBOBOX_CLOSEUP(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_COMBOBOX_CLOSEUP, winid, wxCommandEventHandler(func))
// Generic command events // Generic command events
#define EVT_COMMAND_LEFT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_CLICK, winid, wxCommandEventHandler(func)) #define EVT_COMMAND_LEFT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_CLICK, winid, wxCommandEventHandler(func))

View File

@@ -54,6 +54,16 @@
Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in
the combobox (notice that the combobox must have been created with the combobox (notice that the combobox must have been created with
wxTE_PROCESS_ENTER style to receive this event). wxTE_PROCESS_ENTER style to receive this event).
@event{EVT_COMBOX_DROPDOWN(id, func)}
Process a wxEVT_COMMAND_COMBOBOX_DROPDOWN event, which is generated
when the list box part of the combo box is shown (drops down).
Notice that this event is currently only supported by wxMSW and
wxGTK with GTK+ 2.10 or later.
@event{EVT_COMBOX_CLOSEUP(id, func)}
Process a wxEVT_COMMAND_COMBOBOX_CLOSEUP event, which is generated
when the list box of the combo box disappears (closes up). This
event is only generated for the same platforms as
wxEVT_COMMAND_COMBOBOX_DROPDOWN above.
@endEventTable @endEventTable
@library{wxcore} @library{wxcore}

View File

@@ -114,6 +114,8 @@ protected:
void OnButtonSetValue(wxCommandEvent& event); void OnButtonSetValue(wxCommandEvent& event);
void OnButtonSetCurrent(wxCommandEvent& event); void OnButtonSetCurrent(wxCommandEvent& event);
void OnDropdown(wxCommandEvent& event);
void OnCloseup(wxCommandEvent& event);
void OnComboBox(wxCommandEvent& event); void OnComboBox(wxCommandEvent& event);
void OnComboText(wxCommandEvent& event); void OnComboText(wxCommandEvent& event);
@@ -199,6 +201,8 @@ BEGIN_EVENT_TABLE(ComboboxWidgetsPage, WidgetsPage)
EVT_UPDATE_UI(ComboPage_SetCurrent, ComboboxWidgetsPage::OnUpdateUISetCurrent) EVT_UPDATE_UI(ComboPage_SetCurrent, ComboboxWidgetsPage::OnUpdateUISetCurrent)
EVT_COMBOBOX(ComboPage_Combo, ComboboxWidgetsPage::OnComboBox) EVT_COMBOBOX(ComboPage_Combo, ComboboxWidgetsPage::OnComboBox)
EVT_COMBOBOX_DROPDOWN(ComboPage_Combo, ComboboxWidgetsPage::OnDropdown)
EVT_COMBOBOX_CLOSEUP(ComboPage_Combo, ComboboxWidgetsPage::OnCloseup)
EVT_TEXT(ComboPage_Combo, ComboboxWidgetsPage::OnComboText) EVT_TEXT(ComboPage_Combo, ComboboxWidgetsPage::OnComboText)
EVT_TEXT_ENTER(ComboPage_Combo, ComboboxWidgetsPage::OnComboText) EVT_TEXT_ENTER(ComboPage_Combo, ComboboxWidgetsPage::OnComboText)
@@ -636,6 +640,16 @@ void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
CreateCombo(); CreateCombo();
} }
void ComboboxWidgetsPage::OnDropdown(wxCommandEvent& WXUNUSED(event))
{
wxLogMessage(_T("Combobox dropped down"));
}
void ComboboxWidgetsPage::OnCloseup(wxCommandEvent& WXUNUSED(event))
{
wxLogMessage(_T("Combobox closed up"));
}
#endif //wxUSE_COMBOBOX #endif //wxUSE_COMBOBOX
#endif #endif

View File

@@ -177,6 +177,8 @@ wxDEFINE_EVENT( wxEVT_COMMAND_TOOL_ENTER, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEvent ); wxDEFINE_EVENT( wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, wxCommandEvent ); wxDEFINE_EVENT( wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, wxCommandEvent ); wxDEFINE_EVENT( wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_COMMAND_COMBOBOX_DROPDOWN, wxCommandEvent);
wxDEFINE_EVENT( wxEVT_COMMAND_COMBOBOX_CLOSEUP, wxCommandEvent);
// Mouse event types // Mouse event types
wxDEFINE_EVENT( wxEVT_LEFT_DOWN, wxMouseEvent ); wxDEFINE_EVENT( wxEVT_LEFT_DOWN, wxMouseEvent );

View File

@@ -44,6 +44,20 @@ gtkcombobox_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{ {
combo->SendSelectionChangedEvent(wxEVT_COMMAND_COMBOBOX_SELECTED); combo->SendSelectionChangedEvent(wxEVT_COMMAND_COMBOBOX_SELECTED);
} }
static void
gtkcombobox_popupshown_callback(GObject *WXUNUSED(gobject),
GParamSpec *WXUNUSED(param_spec),
wxComboBox *combo)
{
gboolean isShown;
g_object_get( combo->m_widget, "popup-shown", &isShown, NULL );
wxCommandEvent event( isShown ? wxEVT_COMMAND_COMBOBOX_DROPDOWN
: wxEVT_COMMAND_COMBOBOX_CLOSEUP,
combo->GetId() );
event.SetEventObject( combo );
combo->HandleWindowEvent( event );
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -158,6 +172,12 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
g_signal_connect_after (m_widget, "changed", g_signal_connect_after (m_widget, "changed",
G_CALLBACK (gtkcombobox_changed_callback), this); G_CALLBACK (gtkcombobox_changed_callback), this);
if ( gtk_check_version(2,10,0) )
{
g_signal_connect (m_widget, "notify::popup-shown",
G_CALLBACK (gtkcombobox_popupshown_callback), this);
}
SetInitialSize(size); // need this too because this is a wxControlWithItems SetInitialSize(size); // need this too because this is a wxControlWithItems
return true; return true;
@@ -210,6 +230,8 @@ void wxComboBox::DisableEvents()
g_signal_handlers_block_by_func(m_widget, g_signal_handlers_block_by_func(m_widget,
(gpointer)gtkcombobox_changed_callback, this); (gpointer)gtkcombobox_changed_callback, this);
g_signal_handlers_block_by_func(m_widget,
(gpointer)gtkcombobox_popupshown_callback, this);
} }
void wxComboBox::EnableEvents() void wxComboBox::EnableEvents()
@@ -220,6 +242,8 @@ void wxComboBox::EnableEvents()
g_signal_handlers_unblock_by_func(m_widget, g_signal_handlers_unblock_by_func(m_widget,
(gpointer)gtkcombobox_changed_callback, this); (gpointer)gtkcombobox_changed_callback, this);
g_signal_handlers_unblock_by_func(m_widget,
(gpointer)gtkcombobox_popupshown_callback, this);
} }
GtkWidget* wxComboBox::GetConnectWidget() GtkWidget* wxComboBox::GetConnectWidget()

View File

@@ -342,8 +342,19 @@ bool wxComboBox::MSWCommand(WXUINT param, WXWORD id)
// down is cancelled (see #8474) // down is cancelled (see #8474)
m_lastAcceptedSelection = wxID_NONE; m_lastAcceptedSelection = wxID_NONE;
} }
{
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_DROPDOWN, GetId());
event.SetEventObject(this);
ProcessCommand(event);
}
break;
case CBN_CLOSEUP:
{
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_CLOSEUP, GetId());
event.SetEventObject(this);
ProcessCommand(event);
}
break; break;
case CBN_SELENDOK: case CBN_SELENDOK:
#ifndef __SMARTPHONE__ #ifndef __SMARTPHONE__
// we need to reset this to prevent the selection from being undone // we need to reset this to prevent the selection from being undone