Kaydet (Commit) a6f78bf8 authored tarafından Niklas Johansson's avatar Niklas Johansson Kaydeden (comit) Thomas Arnhold

Treeview may lose focus when left/right arrow is used

In a treeview, for example the hierarchal view of the
styles and formatting panel, if your not on a node that is
expandable or collapsable when you press the left or right
arrow key, the focus will move away from the tree view in
a very awkward way. This patch makes the control work more
like a native treeview.

At this point I don't feel confident about the surrounding
code to avoid the code duplication that this patch adds.

Change-Id: Ibd04cf5329b4d226aac102d214a45e45811982e7
Reviewed-on: https://gerrit.libreoffice.org/10956Reviewed-by: 's avatarThomas Arnhold <thomas@arnhold.org>
Tested-by: 's avatarThomas Arnhold <thomas@arnhold.org>
üst 10176b1b
...@@ -2237,8 +2237,13 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) ...@@ -2237,8 +2237,13 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
case KEY_RIGHT: case KEY_RIGHT:
{ {
if( bSubLstOpLR && IsNowExpandable() ) if( bSubLstOpLR )
pView->Expand( pCursor ); {
// only try to expand if sublist is expandable,
// otherwise ignore the key press
if( IsNowExpandable() )
pView->Expand( pCursor );
}
else if ( bIsCellFocusEnabled && pCursor ) else if ( bIsCellFocusEnabled && pCursor )
{ {
if ( nCurTabPos < ( pView->TabCount() - 1 /*!2*/ ) ) if ( nCurTabPos < ( pView->TabCount() - 1 /*!2*/ ) )
...@@ -2304,8 +2309,17 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) ...@@ -2304,8 +2309,17 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
} }
} }
} }
else if( bSubLstOpLR && IsExpandable() ) else if( bSubLstOpLR )
pView->Collapse( pCursor ); {
if( IsExpandable() && pView->IsExpanded( pCursor ) )
pView->Collapse( pCursor );
else
{
pNewCursor = pView->GetParent( pCursor );
if( pNewCursor )
SetCursor( pNewCursor );
}
}
else else
bKeyUsed = false; bKeyUsed = false;
break; break;
......
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