improved focus handling, still need to handle the tab change

This commit is contained in:
dickelbeck 2010-01-22 19:59:27 +00:00
parent 7ab4a9bf2c
commit 7399fdc398
3 changed files with 28 additions and 11 deletions

View File

@ -35,6 +35,7 @@
#include <wx/wx.h>
#include <wx/statbmp.h>
#include <wx/notebook.h>
#include "macros.h"
#include "common.h"
@ -350,6 +351,15 @@ void LAYER_WIDGET::OnRenderCheckBox( wxCommandEvent& event )
}
void LAYER_WIDGET::OnTabChange( wxNotebookEvent& event )
{
// printf("OnTabChange\n");
// passOnFocus(); // this segfaults, cannot enable it.
// maybe we need to find a way to call the stock tab change event handler
// first, then call passOnFocus() before we consider this event done.
}
wxWindow* LAYER_WIDGET::getLayerComp( int aSizerNdx )
{
if( (unsigned) aSizerNdx < m_LayersFlexGridSizer->GetChildren().GetCount() )
@ -456,19 +466,16 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
void LAYER_WIDGET::passOnFocus()
{
wxWindow* parent = GetParent();
parent->SetFocus();
// printf( "passOnFocus() %p %p\n", parent, m_OriginalParent );
m_FocusOwner->SetFocus();
}
//-----<public>-------------------------------------------------------
LAYER_WIDGET::LAYER_WIDGET( wxWindow* parent ) :
LAYER_PANEL_BASE( parent )
LAYER_WIDGET::LAYER_WIDGET( wxWindow* aParent, wxWindow* aFocusOwner ) :
LAYER_PANEL_BASE( aParent )
{
m_OriginalParent = parent;
m_FocusOwner = aFocusOwner;
m_CurrentRow = -1;
@ -486,6 +493,10 @@ LAYER_WIDGET::LAYER_WIDGET( wxWindow* parent ) :
Connect( ID_SHOW_ALL_COPPERS, ID_SHOW_NO_COPPERS,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( LAYER_WIDGET::OnPopupSelection ), NULL, this );
// trap the tab changes so that we can call passOnFocus().
m_notebook->Connect( -1, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
wxNotebookEventHandler( LAYER_WIDGET::OnTabChange ) );
}

View File

@ -74,7 +74,7 @@ public:
protected:
wxWindow* m_OriginalParent;
wxWindow* m_FocusOwner;
wxBitmap* m_BlankBitmap;
wxBitmap* m_RightArrowBitmap;
wxSize m_BitmapSize;
@ -116,6 +116,9 @@ protected:
void OnRenderCheckBox( wxCommandEvent& event );
void OnTabChange( wxNotebookEvent& event );
/**
* Function getLayerComp
* returns the component within the m_LayersFlexGridSizer at aSizerNdx or
@ -148,8 +151,11 @@ protected:
public:
/** Constructor */
LAYER_WIDGET( wxWindow* parent );
/** Constructor
* @param aFocusOwner is the window that should be sent the focus after
* every operation.
*/
LAYER_WIDGET( wxWindow* aParent, wxWindow* aFocusOwner );
/**
* Function GetBestSize

View File

@ -228,7 +228,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
m_show_microwave_tools = false;
m_show_layer_manager_tools = true;
m_Layers = new LYRS( this );
m_Layers = new LYRS( this, DrawPanel );
SetBoard( new BOARD( NULL, this ) );