[Libreoffice-commits] core.git: framework/source vcl/inc vcl/source
Jim Raykowski (via logerrit)
logerrit at kemper.freedesktop.org
Sat May 4 00:36:09 UTC 2019
framework/source/uielement/toolbarmanager.cxx | 8 +++++
vcl/inc/toolbox.h | 1
vcl/source/window/toolbox.cxx | 38 +++++++++++++++++++-------
vcl/source/window/toolbox2.cxx | 1
4 files changed, 38 insertions(+), 10 deletions(-)
New commits:
commit 3f6fcaa97e3f75c5f12febe821c63f0c2f96e07a
Author: Jim Raykowski <raykowj at gmail.com>
AuthorDate: Wed May 1 22:18:30 2019 -0800
Commit: Jim Raykowski <raykowj at gmail.com>
CommitDate: Sat May 4 02:35:33 2019 +0200
tdf#105881 Toolbar keyboard navigation fixes
This patch makes toolbar keyboard navigation wrap to the begining or end
toolbar item and enables access to the overflow menu using the keyboard.
Change-Id: I5975b0f731beb00cf26f8e8a33e6ea4fa9322881
Reviewed-on: https://gerrit.libreoffice.org/71718
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj at gmail.com>
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 280958311ae4..e64eb89944ce 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -62,6 +62,7 @@
#include <comphelper/sequence.hxx>
#include <svtools/miscopt.hxx>
#include <svtools/imgdef.hxx>
+#include <vcl/event.hxx>
#include <vcl/svapp.hxx>
#include <vcl/menu.hxx>
#include <vcl/syswin.hxx>
@@ -1567,6 +1568,13 @@ IMPL_LINK( ToolBarManager, MenuButton, ToolBox*, pToolBar, void )
pOverflowToolBar->EnableDocking();
pOverflowToolBar->AddEventListener( LINK( this, ToolBarManager, OverflowEventListener ) );
vcl::Window::GetDockingManager()->StartPopupMode( pToolBar, pOverflowToolBar, FloatWinPopupFlags::AllMouseButtonClose );
+
+ // send HOME key to subtoolbar in order to select first item if keyboard activated
+ if(pToolBar->IsKeyEvent() )
+ {
+ ::KeyEvent aEvent( 0, vcl::KeyCode( KEY_HOME ) );
+ pOverflowToolBar->KeyInput(aEvent);
+ }
}
IMPL_LINK( ToolBarManager, OverflowEventListener, VclWindowEvent&, rWindowEvent, void )
diff --git a/vcl/inc/toolbox.h b/vcl/inc/toolbox.h
index 4540cb0c109c..1c9fb88d15a8 100644
--- a/vcl/inc/toolbox.h
+++ b/vcl/inc/toolbox.h
@@ -147,6 +147,7 @@ struct ImplToolBoxPrivateData
mbKeyInputDisabled:1, // no KEY input if all items disabled, closing/docking will be allowed though
mbIsPaintLocked:1, // don't allow paints
mbMenubuttonSelected:1, // menu button is highlighted
+ mbMenubuttonWasLastSelected:1, // menu button was highlighted when focus was lost
mbNativeButtons:1, // system supports native toolbar buttons
mbWillUsePopupMode:1, // this toolbox will be opened in popup mode
mbDropDownByKeyboard:1; // tells whether a dropdown was started by key input
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index c7bc19f089c1..6ff26a004ad5 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -3896,11 +3896,20 @@ bool ToolBox::EventNotify( NotifyEvent& rNEvt )
if( rNEvt.GetWindow() == this )
{
// the toolbar itself got the focus
- if( mnLastFocusItemId != 0 )
+ if( mnLastFocusItemId != 0 || mpData->mbMenubuttonWasLastSelected )
{
// restore last item
- ImplChangeHighlight( ImplGetItem( mnLastFocusItemId ) );
- mnLastFocusItemId = 0;
+ if( mpData->mbMenubuttonWasLastSelected )
+ {
+ ImplChangeHighlight( nullptr );
+ mpData->mbMenubuttonSelected = true;
+ InvalidateMenuButton();
+ }
+ else
+ {
+ ImplChangeHighlight( ImplGetItem( mnLastFocusItemId ) );
+ mnLastFocusItemId = 0;
+ }
}
else if( (GetGetFocusFlags() & (GetFocusFlags::Backward|GetFocusFlags::Tab) ) == (GetFocusFlags::Backward|GetFocusFlags::Tab))
// Shift-TAB was pressed in the parent
@@ -3934,6 +3943,7 @@ bool ToolBox::EventNotify( NotifyEvent& rNEvt )
{
// deselect
ImplHideFocus();
+ mpData->mbMenubuttonWasLastSelected = false;
mnHighItemId = 0;
mnCurPos = ITEM_NOTFOUND;
}
@@ -4458,18 +4468,17 @@ bool ToolBox::ImplOpenItem( vcl::KeyCode aKeyCode )
{
if( ImplCloseLastPopup( GetParent() ) )
return bRet;
-
+ mbIsKeyEvent = true;
if ( maMenuButtonHdl.IsSet() )
maMenuButtonHdl.Call( this );
else
ExecuteCustomMenu( mpData->maMenubuttonItem.maRect );
+ mpData->mbMenubuttonWasLastSelected = true;
+ mbIsKeyEvent = false;
}
else if( mnHighItemId && ImplGetItem( mnHighItemId ) &&
(ImplGetItem( mnHighItemId )->mnBits & ToolBoxItemBits::DROPDOWN) )
{
- if( ImplCloseLastPopup( GetParent() ) )
- return bRet;
-
mnDownItemId = mnCurItemId = mnHighItemId;
mnCurPos = GetItemPos( mnCurItemId );
mnLastFocusItemId = mnCurItemId; // save item id for possible later focus restore
@@ -4844,6 +4853,7 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
// menubutton highlighted ?
if( mpData->mbMenubuttonSelected )
{
+ mpData->mbMenubuttonSelected = false;
if( bUp )
{
// select last valid non-clipped item
@@ -4880,6 +4890,7 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
if( (it != mpData->m_aItems.end() && &(*it) == ImplGetFirstClippedItem()) && IsMenuEnabled() )
{
ImplChangeHighlight( nullptr );
+ mpData->mbMenubuttonSelected = true;
InvalidateMenuButton();
}
else
@@ -4891,9 +4902,10 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
// Select last valid item
// docked toolbars have the menubutton as last item - if this button is enabled
- if( IsMenuEnabled() && !ImplIsFloatingMode() )
+ if( ImplHasClippedItems() && IsMenuEnabled() && !ImplIsFloatingMode() )
{
ImplChangeHighlight( nullptr );
+ mpData->mbMenubuttonSelected = true;
InvalidateMenuButton();
}
else
@@ -4926,9 +4938,10 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
return false;
// highlight the menu button if it is the last item
- if( IsMenuEnabled() && !ImplIsFloatingMode() )
+ if( ImplHasClippedItems() && IsMenuEnabled() && !ImplIsFloatingMode() )
{
ImplChangeHighlight( nullptr );
+ mpData->mbMenubuttonSelected = true;
InvalidateMenuButton();
return true;
}
@@ -4944,9 +4957,10 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
return false;
// highlight the menu button if it is the last item
- if( IsMenuEnabled() && !ImplIsFloatingMode() )
+ if( ImplHasClippedItems() && IsMenuEnabled() && !ImplIsFloatingMode() )
{
ImplChangeHighlight( nullptr );
+ mpData->mbMenubuttonSelected = true;
InvalidateMenuButton();
return true;
}
@@ -4966,6 +4980,7 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
{
// select the menu button if a clipped item would be selected
ImplChangeHighlight( nullptr );
+ mpData->mbMenubuttonSelected = true;
InvalidateMenuButton();
}
else if( i != nCount )
@@ -4994,6 +5009,7 @@ void ToolBox::ImplHideFocus()
{
if( mnHighItemId )
{
+ mpData->mbMenubuttonWasLastSelected = false;
ImplToolItem* pItem = ImplGetItem( mnHighItemId );
if( pItem && pItem->mpWindow )
{
@@ -5005,7 +5021,9 @@ void ToolBox::ImplHideFocus()
if ( mpData && mpData->mbMenubuttonSelected )
{
+ mpData->mbMenubuttonWasLastSelected = true;
// remove highlight from menubutton
+ mpData->mbMenubuttonSelected = false;
InvalidateMenuButton();
}
}
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 2ae429134a28..9981da0ada76 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -62,6 +62,7 @@ ImplToolBoxPrivateData::ImplToolBoxPrivateData()
mbAssumeFloating = false;
mbKeyInputDisabled = false;
mbMenubuttonSelected = false;
+ mbMenubuttonWasLastSelected = false;
mbWillUsePopupMode = false;
mbDropDownByKeyboard = false;
}
More information about the Libreoffice-commits
mailing list