Commit 2f5b226d authored by Clément Stenac's avatar Clément Stenac

Selection is almost working correctly

parent b083e1e9
...@@ -212,6 +212,7 @@ void CtrlTree::onPositionChange() ...@@ -212,6 +212,7 @@ void CtrlTree::onPositionChange()
void CtrlTree::handleEvent( EvtGeneric &rEvent ) void CtrlTree::handleEvent( EvtGeneric &rEvent )
{ {
VarTree::Iterator toShow; bool needShow = false;
if( rEvent.getAsString().find( "key:down" ) != string::npos ) if( rEvent.getAsString().find( "key:down" ) != string::npos )
{ {
int key = ((EvtKey&)rEvent).getKey(); int key = ((EvtKey&)rEvent).getKey();
...@@ -233,9 +234,9 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent ) ...@@ -233,9 +234,9 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
if( nextWasSelected ) if( nextWasSelected )
{ {
m_pLastSelected = &*it; m_pLastSelected = &*it;
needShow = true; toShow = it;
} }
} }
ensureVisible( it );
} }
else if( key == KEY_DOWN ) else if( key == KEY_DOWN )
{ {
...@@ -249,13 +250,13 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent ) ...@@ -249,13 +250,13 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
if( previousWasSelected ) if( previousWasSelected )
{ {
m_pLastSelected = &*it; m_pLastSelected = &*it;
needShow = true; toShow = it;
previousWasSelected = false; previousWasSelected = false;
} }
else else
{ {
previousWasSelected = ( &*it == m_pLastSelected ); previousWasSelected = ( &*it == m_pLastSelected );
} }
ensureVisible( it );
} }
else if( key == KEY_RIGHT ) else if( key == KEY_RIGHT )
{ {
...@@ -310,6 +311,8 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent ) ...@@ -310,6 +311,8 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
} }
} }
} }
if( needShow )
ensureVisible( toShow );
// Redraw the control // Redraw the control
makeImage(); makeImage();
...@@ -475,7 +478,7 @@ bool CtrlTree::ensureVisible( VarTree::Iterator item ) ...@@ -475,7 +478,7 @@ bool CtrlTree::ensureVisible( VarTree::Iterator item )
for( it = m_rTree.begin(); it != m_rTree.end(); for( it = m_rTree.begin(); it != m_rTree.end();
it = m_rTree.getNextVisibleItem( it ) ) it = m_rTree.getNextVisibleItem( it ) )
{ {
if( it == item ) break; if( it->m_id == item->m_id ) break;
focusItemIndex++; focusItemIndex++;
} }
return ensureVisible( focusItemIndex ); return ensureVisible( focusItemIndex );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment