Have wxComboCtrl generate wxEVT_COMMAND_COMBOBOX_DROPDOWN and wxEVT_COMMAND_COMBOBOX_CLOSEUP events

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62136 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli 2009-09-26 09:15:29 +00:00
parent f4c24d3da4
commit a1d5aa9361
4 changed files with 59 additions and 20 deletions

View File

@ -158,7 +158,7 @@ public:
// show/hide popup window
virtual void ShowPopup();
virtual void HidePopup();
virtual void HidePopup(bool generateEvent=false);
// Override for totally custom combo action
virtual void OnButtonClick();
@ -403,7 +403,7 @@ public:
bool IsCreated() const { return m_iFlags & wxCC_IFLAG_CREATED ? true : false; }
// common code to be called on popup hide/dismiss
void OnPopupDismiss();
void OnPopupDismiss(bool generateEvent);
// PopupShown states
enum

View File

@ -304,6 +304,12 @@ struct wxComboCtrlFeatures
@event{EVT_TEXT_ENTER(id, func)}
Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in
the combo control.
@event{EVT_COMBOX_DROPDOWN(id, func)}
Process a wxEVT_COMMAND_COMBOBOX_DROPDOWN event, which is generated
when the popup window is shown (drops down).
@event{EVT_COMBOX_CLOSEUP(id, func)}
Process a wxEVT_COMMAND_COMBOBOX_CLOSEUP event, which is generated
when the popup window of the combo control disappears (closes up).
@endEventTable
@library{wxbase}
@ -504,8 +510,12 @@ public:
/**
Dismisses the popup window.
@param generateEvent
Set this to @true in order to generate
wxEVT_COMMAND_COMBOBOX_CLOSEUP event.
*/
virtual void HidePopup();
virtual void HidePopup(bool generateEvent=false);
/**
Returns @true if the popup is currently shown

View File

@ -113,6 +113,8 @@ protected:
void OnButtonAddMany(wxCommandEvent& event);
void OnComboBox(wxCommandEvent& event);
void OnDropDown(wxCommandEvent& event);
void OnCloseUp(wxCommandEvent& event);
void OnComboText(wxCommandEvent& event);
void OnCheckOrRadioBox(wxCommandEvent& event);
@ -218,6 +220,8 @@ BEGIN_EVENT_TABLE(ODComboboxWidgetsPage, WidgetsPage)
EVT_UPDATE_UI(ODComboPage_ChangeText, ODComboboxWidgetsPage::OnUpdateUIDeleteSelButton)
EVT_UPDATE_UI(ODComboPage_DeleteSel, ODComboboxWidgetsPage::OnUpdateUIDeleteSelButton)
EVT_COMBOBOX_DROPDOWN(ODComboPage_Combo, ODComboboxWidgetsPage::OnDropDown)
EVT_COMBOBOX_CLOSEUP(ODComboPage_Combo, ODComboboxWidgetsPage::OnCloseUp)
EVT_COMBOBOX(ODComboPage_Combo, ODComboboxWidgetsPage::OnComboBox)
EVT_TEXT(ODComboPage_Combo, ODComboboxWidgetsPage::OnComboText)
EVT_TEXT_ENTER(ODComboPage_Combo, ODComboboxWidgetsPage::OnComboText)
@ -844,4 +848,14 @@ wxBitmap ODComboboxWidgetsPage::CreateBitmap(const wxColour& colour)
return bmp;
}
void ODComboboxWidgetsPage::OnDropDown(wxCommandEvent& WXUNUSED(event))
{
wxLogMessage(wxT("Combobox dropped down"));
}
void ODComboboxWidgetsPage::OnCloseUp(wxCommandEvent& WXUNUSED(event))
{
wxLogMessage(wxT("Combobox closed up"));
}
#endif //wxUSE_ODCOMBOBOX

View File

@ -291,7 +291,7 @@ void wxComboFrameEventHandler::OnIdle( wxIdleEvent& event )
winFocused != m_combo->GetButton() // GTK (atleast) requires this
)
{
m_combo->HidePopup();
m_combo->HidePopup(true);
}
event.Skip();
@ -299,37 +299,37 @@ void wxComboFrameEventHandler::OnIdle( wxIdleEvent& event )
void wxComboFrameEventHandler::OnMenuEvent( wxMenuEvent& event )
{
m_combo->HidePopup();
m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnMouseEvent( wxMouseEvent& event )
{
m_combo->HidePopup();
m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnClose( wxCloseEvent& event )
{
m_combo->HidePopup();
m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnActivate( wxActivateEvent& event )
{
m_combo->HidePopup();
m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnResize( wxSizeEvent& event )
{
m_combo->HidePopup();
m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnMove( wxMoveEvent& event )
{
m_combo->HidePopup();
m_combo->HidePopup(true);
event.Skip();
}
@ -413,7 +413,7 @@ void wxComboPopupWindow::OnDismiss()
wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxComboCtrlBase)),
wxT("parent might not be wxComboCtrl, but check IMPLEMENT_DYNAMIC_CLASS(2) macro for correctness") );
combo->OnPopupDismiss();
combo->OnPopupDismiss(true);
}
#endif // USES_WXPOPUPTRANSIENTWINDOW
@ -476,7 +476,7 @@ void wxComboPopupWindowEvtHandler::OnActivate( wxActivateEvent& event )
if ( !event.GetActive() )
{
// Tell combo control that we are dismissed.
m_combo->HidePopup();
m_combo->HidePopup(true);
event.Skip();
}
@ -551,7 +551,7 @@ bool wxComboPopup::LazyCreate()
void wxComboPopup::Dismiss()
{
m_combo->HidePopup();
m_combo->HidePopup(true);
}
// ----------------------------------------------------------------------------
@ -1624,7 +1624,7 @@ bool wxComboCtrlBase::PreprocessMouseEvent( wxMouseEvent& event,
if ( IsPopupWindowState(Visible) &&
( evtType == wxEVT_LEFT_DOWN || evtType == wxEVT_RIGHT_DOWN ) )
{
HidePopup();
HidePopup(true);
return true;
}
}
@ -1652,7 +1652,7 @@ void wxComboCtrlBase::HandleNormalMouseEvent( wxMouseEvent& event )
#if USES_WXPOPUPWINDOW
// Click here always hides the popup.
if ( m_popupWinType == POPUPWIN_WXPOPUPWINDOW )
HidePopup();
HidePopup(true);
#endif
}
else
@ -1808,7 +1808,7 @@ void wxComboCtrlBase::CreatePopup()
// Destroy popup window and the child control
void wxComboCtrlBase::DestroyPopup()
{
HidePopup();
HidePopup(true);
if ( m_popup )
m_popup->RemoveEventHandler(m_popupExtraHandler);
@ -1871,9 +1871,17 @@ void wxComboCtrlBase::OnButtonClick()
// Derived classes can override this method for totally custom
// popup action
if ( !IsPopupWindowState(Visible) )
{
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_DROPDOWN, GetId());
event.SetEventObject(this);
ProcessCommand(event);
ShowPopup();
}
else
HidePopup();
{
HidePopup(true);
}
}
void wxComboCtrlBase::ShowPopup()
@ -2092,7 +2100,7 @@ void wxComboCtrlBase::DoShowPopup( const wxRect& rect, int WXUNUSED(flags) )
Refresh();
}
void wxComboCtrlBase::OnPopupDismiss()
void wxComboCtrlBase::OnPopupDismiss(bool generateEvent)
{
// Just in case, avoid double dismiss
if ( IsPopupWindowState(Hidden) )
@ -2144,9 +2152,16 @@ void wxComboCtrlBase::OnPopupDismiss()
Refresh();
SetFocus();
if ( generateEvent )
{
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_CLOSEUP, GetId());
event.SetEventObject(this);
ProcessCommand(event);
}
}
void wxComboCtrlBase::HidePopup()
void wxComboCtrlBase::HidePopup(bool generateEvent)
{
// Should be able to call this without popup interface
if ( IsPopupWindowState(Hidden) )
@ -2158,7 +2173,7 @@ void wxComboCtrlBase::HidePopup()
m_winPopup->Hide();
OnPopupDismiss();
OnPopupDismiss(generateEvent);
}
// ----------------------------------------------------------------------------