Get rid of wxComboPopupWindowEvtHandler in wxComboCtrlBase too
Use Bind() calls instead of another event handler too, for the same reasons as in the previous commit.
This commit is contained in:
@@ -575,6 +575,10 @@ protected:
|
|||||||
void OnTextFocus(wxFocusEvent& event);
|
void OnTextFocus(wxFocusEvent& event);
|
||||||
void OnTextKey(wxKeyEvent& event);
|
void OnTextKey(wxKeyEvent& event);
|
||||||
|
|
||||||
|
void OnPopupActivate(wxActivateEvent& event);
|
||||||
|
void OnPopupKey(wxKeyEvent& event);
|
||||||
|
void OnPopupSize(wxSizeEvent& event);
|
||||||
|
|
||||||
// Set customization flags (directs how wxComboCtrlBase helpers behave)
|
// Set customization flags (directs how wxComboCtrlBase helpers behave)
|
||||||
void Customize( wxUint32 flags ) { m_iFlags |= flags; }
|
void Customize( wxUint32 flags ) { m_iFlags |= flags; }
|
||||||
|
|
||||||
@@ -636,9 +640,6 @@ protected:
|
|||||||
// this is for the control in popup
|
// this is for the control in popup
|
||||||
wxEvtHandler* m_popupEvtHandler;
|
wxEvtHandler* m_popupEvtHandler;
|
||||||
|
|
||||||
// this is for the popup window
|
|
||||||
wxEvtHandler* m_popupWinEvtHandler;
|
|
||||||
|
|
||||||
// main (ie. topmost) window of a composite control (default = this)
|
// main (ie. topmost) window of a composite control (default = this)
|
||||||
wxWindow* m_mainCtrlWnd;
|
wxWindow* m_mainCtrlWnd;
|
||||||
|
|
||||||
|
@@ -527,63 +527,26 @@ void wxComboPopupWindow::OnDismiss()
|
|||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxComboPopupWindowEvtHandler does bulk of the custom event handling
|
// custom event handling for popup window is done in wxComboCtrlBase so we can
|
||||||
// of a popup window. It is separate so we can have different types
|
// have different types of popup windows.
|
||||||
// of popup windows.
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxComboPopupWindowEvtHandler : public wxEvtHandler
|
void wxComboCtrlBase::OnPopupSize( wxSizeEvent& WXUNUSED(event) )
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
wxComboPopupWindowEvtHandler( wxComboCtrlBase *parent )
|
|
||||||
{
|
|
||||||
m_combo = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnSizeEvent( wxSizeEvent& event );
|
|
||||||
void OnKeyEvent(wxKeyEvent& event);
|
|
||||||
#if USES_GENERICTLW
|
|
||||||
void OnActivate( wxActivateEvent& event );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
#if USES_GENERICTLW
|
|
||||||
void HideOnDeactivate();
|
|
||||||
#endif // USES_GENERICTLW
|
|
||||||
wxComboCtrlBase* m_combo;
|
|
||||||
|
|
||||||
wxDECLARE_EVENT_TABLE();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(wxComboPopupWindowEvtHandler, wxEvtHandler)
|
|
||||||
EVT_KEY_DOWN(wxComboPopupWindowEvtHandler::OnKeyEvent)
|
|
||||||
EVT_KEY_UP(wxComboPopupWindowEvtHandler::OnKeyEvent)
|
|
||||||
EVT_CHAR(wxComboPopupWindowEvtHandler::OnKeyEvent)
|
|
||||||
#if USES_GENERICTLW
|
|
||||||
EVT_ACTIVATE(wxComboPopupWindowEvtHandler::OnActivate)
|
|
||||||
#endif
|
|
||||||
EVT_SIZE(wxComboPopupWindowEvtHandler::OnSizeEvent)
|
|
||||||
wxEND_EVENT_TABLE()
|
|
||||||
|
|
||||||
|
|
||||||
void wxComboPopupWindowEvtHandler::OnSizeEvent( wxSizeEvent& WXUNUSED(event) )
|
|
||||||
{
|
{
|
||||||
// Block the event so that the popup control does not get auto-resized.
|
// Block the event so that the popup control does not get auto-resized.
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxComboPopupWindowEvtHandler::OnKeyEvent( wxKeyEvent& event )
|
void wxComboCtrlBase::OnPopupKey( wxKeyEvent& event )
|
||||||
{
|
{
|
||||||
// Relay keyboard event to the main child controls
|
// Relay keyboard event to the main child controls
|
||||||
wxWindowList children = m_combo->GetPopupWindow()->GetChildren();
|
wxWindowList children = GetPopupWindow()->GetChildren();
|
||||||
wxWindowList::iterator node = children.begin();
|
wxWindowList::iterator node = children.begin();
|
||||||
wxWindow* child = (wxWindow*)*node;
|
wxWindow* child = (wxWindow*)*node;
|
||||||
child->GetEventHandler()->ProcessEvent(event);
|
child->GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USES_GENERICTLW
|
#if USES_GENERICTLW
|
||||||
void wxComboPopupWindowEvtHandler::OnActivate( wxActivateEvent& event )
|
void wxComboCtrlBase::OnPopupActivate( wxActivateEvent& event )
|
||||||
{
|
{
|
||||||
if ( !event.GetActive() )
|
if ( !event.GetActive() )
|
||||||
{
|
{
|
||||||
@@ -593,18 +556,13 @@ void wxComboPopupWindowEvtHandler::OnActivate( wxActivateEvent& event )
|
|||||||
// event handler causes some side effects like calling this handler again (Win 7)
|
// event handler causes some side effects like calling this handler again (Win 7)
|
||||||
// or setting the focus improperly (Win 10), so postpone it slightly.
|
// or setting the focus improperly (Win 10), so postpone it slightly.
|
||||||
// See wxPopupTransientWindow::MSWHandleMessage().
|
// See wxPopupTransientWindow::MSWHandleMessage().
|
||||||
CallAfter(&wxComboPopupWindowEvtHandler::HideOnDeactivate);
|
CallAfter(&wxComboCtrlBase::Dismiss);
|
||||||
#else // !__WXMSW__
|
#else // !__WXMSW__
|
||||||
HideOnDeactivate();
|
Dismiss();
|
||||||
#endif // __WXMSW__ / !__WXMSW__
|
#endif // __WXMSW__ / !__WXMSW__
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxComboPopupWindowEvtHandler::HideOnDeactivate()
|
|
||||||
{
|
|
||||||
m_combo->HidePopup(true);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -2113,8 +2071,14 @@ void wxComboCtrlBase::CreatePopup()
|
|||||||
m_winPopup = new wxComboPopupWindow( this, wxNO_BORDER );
|
m_winPopup = new wxComboPopupWindow( this, wxNO_BORDER );
|
||||||
m_popupWinType = PRIMARY_POPUP_TYPE;
|
m_popupWinType = PRIMARY_POPUP_TYPE;
|
||||||
}
|
}
|
||||||
m_popupWinEvtHandler = new wxComboPopupWindowEvtHandler(this);
|
|
||||||
m_winPopup->PushEventHandler(m_popupWinEvtHandler);
|
m_winPopup->Bind(wxEVT_KEY_DOWN, &wxComboCtrlBase::OnPopupKey, this);
|
||||||
|
m_winPopup->Bind(wxEVT_CHAR, &wxComboCtrlBase::OnPopupKey, this);
|
||||||
|
m_winPopup->Bind(wxEVT_KEY_UP, &wxComboCtrlBase::OnPopupKey, this);
|
||||||
|
#if USES_GENERICTLW
|
||||||
|
m_winPopup->Bind(wxEVT_ACTIVATE, &wxComboCtrlBase::OnPopupActivate, this);
|
||||||
|
#endif
|
||||||
|
m_winPopup->Bind(wxEVT_SIZE, &wxComboCtrlBase::OnPopupSize, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
popupInterface->Create(m_winPopup);
|
popupInterface->Create(m_winPopup);
|
||||||
@@ -2150,8 +2114,6 @@ void wxComboCtrlBase::DestroyPopup()
|
|||||||
|
|
||||||
if ( m_winPopup )
|
if ( m_winPopup )
|
||||||
{
|
{
|
||||||
m_winPopup->RemoveEventHandler(m_popupWinEvtHandler);
|
|
||||||
wxDELETE(m_popupWinEvtHandler);
|
|
||||||
m_winPopup->Destroy();
|
m_winPopup->Destroy();
|
||||||
m_winPopup = NULL;
|
m_winPopup = NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user