Menu

#39 wxSplitterWindow idle event handler prevents setting sash po

open
nobody
None
5
2010-12-23
2010-12-23
No

Problem arises when trying to set sash position of wxSplitterWindow in constructor of inheritet class when using generated CPP Code.

Problematic parts of generated code

for .h file:
void m_splitterPlotOnIdle( wxIdleEvent& )
{
m_splitterPlot->SetSashPosition( 0 );
m_splitterPlot->Disconnect( wxEVT_IDLE, wxIdleEventHandler( AusgabeBasis::m_splitterPlotOnIdle ), NULL, this );
}
for .cpp file:
m_splitterPlot = new wxSplitterWindow( m_panelPlot, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
m_splitterPlot->SetMinimumPaneSize( 1 );
m_splitterPlot->Connect( wxEVT_IDLE, wxIdleEventHandler( AusgabeBasis::m_splitterPlotOnIdle ), NULL, this );
m_scrolledPlotAuswahl = new wxScrolledWindow( m_splitterPlot, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
m_scrolledPlotAuswahl->SetScrollRate( 5, 5 );
m_plot = new mpWindow( m_splitterPlot, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_splitterPlot->SplitVertically( m_scrolledPlotAuswahl, m_plot, 0 );
Problematic part is the idle event handler, wich is called some time after the constructor of inherited class finished and therefore will overwrite changed sash position.

Reference

Problem seems to be introduced with changes from 02-28-2007 Version 3.00.25 (Beta 3): “Now connecting an event handler to idle events for splitter windows to reliably set the initial sash position” Changelog

Suggestions for fix

Remove on idle handler and use parameter of SplitVertically. May reintroduce bug the change was a fix for (which one? could not find one in tracker)
Make use of on idle handler optional for user. Seems not a good idea.
Only use on idle handler if initial sash position is not 0.

Discussion