Delegation of keyEvents from 3D toolbar to 3D canvas.

Fixes: lp:1759803
* https://bugs.launchpad.net/kicad/+bug/1759803
This commit is contained in:
Jeff Young 2018-04-25 14:18:28 +01:00
parent 68e69fe95d
commit 09a6bada03
3 changed files with 16 additions and 3 deletions

View File

@ -123,6 +123,8 @@ class EDA_3D_CANVAS : public HIDPI_GL_CANVAS
*/
void Request_refresh( bool aRedrawImmediately = true );
void OnKeyEvent( wxKeyEvent& event );
private:
void OnPaint( wxPaintEvent &event );
@ -151,8 +153,6 @@ class EDA_3D_CANVAS : public HIDPI_GL_CANVAS
void OnCharHook( wxKeyEvent& event );
void OnKeyEvent( wxKeyEvent& event );
void OnTimerTimeout_Editing( wxTimerEvent& event );
/**

View File

@ -203,6 +203,8 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway,
m_mainToolBar->EnableTool( ID_RENDER_CURRENT_VIEW,
(m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY) );
m_mainToolBar->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( EDA_3D_VIEWER::OnKeyEvent ), NULL, this );
// Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
// in order to receive mouse events. Otherwise, the user has to click somewhere on
// the canvas before it will respond to mouse wheel events.
@ -213,6 +215,8 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway,
EDA_3D_VIEWER::~EDA_3D_VIEWER()
{
m_mainToolBar->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( EDA_3D_VIEWER::OnKeyEvent ), NULL, this );
m_auimgr.UnInit();
// m_canvas delete will be called by wxWidget manager
@ -904,6 +908,15 @@ void EDA_3D_VIEWER::OnRightClick( const wxPoint &MousePos, wxMenu *PopMenu )
}
void EDA_3D_VIEWER::OnKeyEvent( wxKeyEvent& event )
{
if( m_canvas )
return m_canvas->OnKeyEvent( event );
event.Skip();
}
void EDA_3D_VIEWER::RedrawActiveWindow( wxDC *DC, bool EraseBg )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::RedrawActiveWindow" ) );

View File

@ -202,8 +202,8 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER
void LoadSettings( wxConfigBase *aCfg ) override;
void OnLeftClick( wxDC *DC, const wxPoint &MousePos );
void OnRightClick( const wxPoint &MousePos, wxMenu *PopMenu );
void OnKeyEvent( wxKeyEvent& event );
void RedrawActiveWindow( wxDC *DC, bool EraseBg );