More robust method of regaining keyboard focus (GAL).
This commit is contained in:
parent
d3e276387d
commit
9d27caca75
|
@ -60,6 +60,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
|
||||||
m_view = NULL;
|
m_view = NULL;
|
||||||
m_painter = NULL;
|
m_painter = NULL;
|
||||||
m_eventDispatcher = NULL;
|
m_eventDispatcher = NULL;
|
||||||
|
m_lostFocus = false;
|
||||||
|
|
||||||
SwitchBackend( aGalType );
|
SwitchBackend( aGalType );
|
||||||
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
|
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
|
||||||
|
@ -76,6 +77,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
|
||||||
|
|
||||||
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
|
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
|
||||||
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
|
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
|
||||||
|
Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), NULL, this );
|
||||||
|
|
||||||
const wxEventType events[] =
|
const wxEventType events[] =
|
||||||
{
|
{
|
||||||
|
@ -153,13 +155,6 @@ void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent )
|
|
||||||
{
|
|
||||||
wxPaintEvent redrawEvent;
|
|
||||||
wxPostEvent( this, redrawEvent );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_PANEL_GAL::Refresh( bool aEraseBackground, const wxRect* aRect )
|
void EDA_DRAW_PANEL_GAL::Refresh( bool aEraseBackground, const wxRect* aRect )
|
||||||
{
|
{
|
||||||
if( m_pendingRefresh )
|
if( m_pendingRefresh )
|
||||||
|
@ -315,6 +310,12 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
|
||||||
|
|
||||||
void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent )
|
void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent )
|
||||||
{
|
{
|
||||||
|
if( m_lostFocus )
|
||||||
|
{
|
||||||
|
SetFocus();
|
||||||
|
m_lostFocus = false;
|
||||||
|
}
|
||||||
|
|
||||||
if( !m_eventDispatcher )
|
if( !m_eventDispatcher )
|
||||||
aEvent.Skip();
|
aEvent.Skip();
|
||||||
else
|
else
|
||||||
|
@ -329,3 +330,16 @@ void EDA_DRAW_PANEL_GAL::onEnter( wxEvent& aEvent )
|
||||||
// Getting focus is necessary in order to receive key events properly
|
// Getting focus is necessary in order to receive key events properly
|
||||||
SetFocus();
|
SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EDA_DRAW_PANEL_GAL::onLostFocus( wxFocusEvent& aEvent )
|
||||||
|
{
|
||||||
|
m_lostFocus = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent )
|
||||||
|
{
|
||||||
|
wxPaintEvent redrawEvent;
|
||||||
|
wxPostEvent( this, redrawEvent );
|
||||||
|
}
|
||||||
|
|
|
@ -155,6 +155,7 @@ protected:
|
||||||
void onSize( wxSizeEvent& aEvent );
|
void onSize( wxSizeEvent& aEvent );
|
||||||
void onEvent( wxEvent& aEvent );
|
void onEvent( wxEvent& aEvent );
|
||||||
void onEnter( wxEvent& aEvent );
|
void onEnter( wxEvent& aEvent );
|
||||||
|
void onLostFocus( wxFocusEvent& aEvent );
|
||||||
void onRefreshTimer( wxTimerEvent& aEvent );
|
void onRefreshTimer( wxTimerEvent& aEvent );
|
||||||
|
|
||||||
static const int MinRefreshPeriod = 17; ///< 60 FPS.
|
static const int MinRefreshPeriod = 17; ///< 60 FPS.
|
||||||
|
@ -191,6 +192,10 @@ protected:
|
||||||
|
|
||||||
/// Processes and forwards events to tools
|
/// Processes and forwards events to tools
|
||||||
TOOL_DISPATCHER* m_eventDispatcher;
|
TOOL_DISPATCHER* m_eventDispatcher;
|
||||||
|
|
||||||
|
/// Flag to indicate that focus should be regained on the next mouse event. It is a workaround
|
||||||
|
/// for cases when the panel loses keyboard focus, so it does not react to hotkeys anymore.
|
||||||
|
bool m_lostFocus;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue