Use EventFilter strategy on GTK; leave FocusLost for MSW & OSX.
This commit is contained in:
parent
136525b870
commit
453dadbc3c
|
@ -48,6 +48,38 @@ wxDEFINE_EVENT( NET_SELECTED, wxCommandEvent );
|
||||||
#define NO_NET _( "<no net>" )
|
#define NO_NET _( "<no net>" )
|
||||||
|
|
||||||
|
|
||||||
|
class POPUP_EVENTFILTER : public wxEventFilter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
POPUP_EVENTFILTER( wxDialog* aPopup ) :
|
||||||
|
m_popup( aPopup )
|
||||||
|
{
|
||||||
|
wxEvtHandler::AddFilter( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
~POPUP_EVENTFILTER() override
|
||||||
|
{
|
||||||
|
wxEvtHandler::RemoveFilter( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
int FilterEvent( wxEvent& aEvent ) override
|
||||||
|
{
|
||||||
|
// Click outside popup cancels
|
||||||
|
if( aEvent.GetEventType() == wxEVT_LEFT_DOWN
|
||||||
|
&& !m_popup->GetScreenRect().Contains( wxGetMousePosition() ) )
|
||||||
|
{
|
||||||
|
m_popup->EndModal( wxID_CANCEL );
|
||||||
|
return Event_Processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Event_Skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxDialog* m_popup;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class NET_SELECTOR_POPUP : public wxDialog
|
class NET_SELECTOR_POPUP : public wxDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -112,6 +144,8 @@ public:
|
||||||
// to catch mouse and key events outside our window.
|
// to catch mouse and key events outside our window.
|
||||||
int ShowModal() override
|
int ShowModal() override
|
||||||
{
|
{
|
||||||
|
POPUP_EVENTFILTER filter( this );
|
||||||
|
|
||||||
Show( true );
|
Show( true );
|
||||||
|
|
||||||
while( !m_retCode )
|
while( !m_retCode )
|
||||||
|
@ -188,6 +222,7 @@ protected:
|
||||||
onMouseMoved( screenPos );
|
onMouseMoved( screenPos );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __WXGTK__
|
||||||
// Check for loss of focus. This will indicate that a window manager processed
|
// Check for loss of focus. This will indicate that a window manager processed
|
||||||
// an activate event without fully involving wxWidgets (and thus our EventFilter
|
// an activate event without fully involving wxWidgets (and thus our EventFilter
|
||||||
// never got notified of the click).
|
// never got notified of the click).
|
||||||
|
@ -197,6 +232,7 @@ protected:
|
||||||
|
|
||||||
if( m_initialized && focus != this && focus != m_netListBox && focus != m_filterCtrl )
|
if( m_initialized && focus != this && focus != m_netListBox && focus != m_filterCtrl )
|
||||||
EndModal( wxID_CANCEL );
|
EndModal( wxID_CANCEL );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hot-track the mouse (for focus and listbox selection)
|
// Hot-track the mouse (for focus and listbox selection)
|
||||||
|
|
Loading…
Reference in New Issue