summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2018-11-22 23:31:37 -0900
committerJim Raykowski <raykowj@gmail.com>2018-12-31 08:03:41 +0100
commitcb834ae5c8d5dbecdbc3729bc21889d97d8b582f (patch)
tree7d8afb720a81ff0a136635c5de629f08d63c6f44
parent639013342e216776d1c6a8a6ff3ce29d1355b8ea (diff)
Provide keyboard navigation to Shortcuts tool box and Hamburger menu in
NotebookbarTabControl Use Ctrl+Right/Left arrow to move focus among current notebookbar tab control tab title, hamburger menu, and shortcuts tool box. Change-Id: Ia7b22ff03fce7148eb411cfe9eaabc247b737cb5 Reviewed-on: https://gerrit.libreoffice.org/63875 Tested-by: Jenkins Reviewed-by: Jim Raykowski <raykowj@gmail.com>
-rw-r--r--include/sfx2/notebookbar/NotebookbarTabControl.hxx4
-rw-r--r--include/vcl/tabctrl.hxx1
-rw-r--r--sfx2/source/notebookbar/NotebookbarTabControl.cxx92
3 files changed, 97 insertions, 0 deletions
diff --git a/include/sfx2/notebookbar/NotebookbarTabControl.hxx b/include/sfx2/notebookbar/NotebookbarTabControl.hxx
index 2ff4d3c48974..f3411d769b71 100644
--- a/include/sfx2/notebookbar/NotebookbarTabControl.hxx
+++ b/include/sfx2/notebookbar/NotebookbarTabControl.hxx
@@ -27,6 +27,8 @@ public:
NotebookbarTabControl( Window* pParent );
~NotebookbarTabControl() override;
+ virtual void KeyInput( const KeyEvent& rKEvt ) override;
+ virtual bool EventNotify( NotifyEvent& rNEvt ) override;
virtual void StateChanged(StateChangedType nStateChange) override;
virtual Size calculateRequisition() const override;
@@ -36,6 +38,8 @@ private:
const OUString& aModuleName,
ToolBox* pShortcuts
);
+ void ArrowStops( sal_uInt16 nCode );
+
DECL_LINK(OpenNotebookbarPopupMenu, NotebookBar*, void);
css::uno::Reference<css::ui::XUIConfigurationListener> m_pListener;
diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx
index 332f92abb4e9..cf64e66efc64 100644
--- a/include/vcl/tabctrl.hxx
+++ b/include/vcl/tabctrl.hxx
@@ -201,6 +201,7 @@ public:
void SetIconClickHdl( Link<NotebookBar*, void> aHdl );
void SetToolBox( ToolBox* pToolBox );
ToolBox* GetToolBox() { return m_pShortcuts; }
+ PushButton* GetOpenMenu() { return m_pOpenMenu; }
virtual sal_uInt16 GetPageId( const Point& rPos ) const override;
virtual void SelectTabPage( sal_uInt16 nPageId ) override;
diff --git a/sfx2/source/notebookbar/NotebookbarTabControl.cxx b/sfx2/source/notebookbar/NotebookbarTabControl.cxx
index 994dbf7d3a3f..2e5f18af3150 100644
--- a/sfx2/source/notebookbar/NotebookbarTabControl.cxx
+++ b/sfx2/source/notebookbar/NotebookbarTabControl.cxx
@@ -126,6 +126,20 @@ public:
mbUseDefaultButtonSize = false;
SetToolboxButtonSize(ToolBoxButtonSize::Small);
}
+
+ virtual void KeyInput( const KeyEvent& rKEvt ) override
+ {
+ if ( rKEvt.GetKeyCode().IsMod1() )
+ {
+ sal_uInt16 nCode( rKEvt.GetKeyCode().GetCode() );
+ if ( nCode == KEY_RIGHT || nCode == KEY_LEFT )
+ {
+ GetParent()->KeyInput( rKEvt );
+ return;
+ }
+ }
+ return sfx2::sidebar::SidebarToolBox::KeyInput( rKEvt );
+ }
};
NotebookbarTabControl::NotebookbarTabControl( Window* pParent )
@@ -139,6 +153,84 @@ NotebookbarTabControl::~NotebookbarTabControl()
{
}
+void NotebookbarTabControl::ArrowStops( sal_uInt16 nCode )
+{
+ ToolBox* pToolBox( GetToolBox() );
+ PushButton* pOpenMenu( GetOpenMenu() );
+
+ if ( nCode == KEY_LEFT )
+ {
+ if ( HasFocus() )
+ {
+ if ( pToolBox )
+ pToolBox->GrabFocus();
+ else if ( pOpenMenu )
+ pOpenMenu->GrabFocus();
+ }
+ else if ( pToolBox && pToolBox->HasFocus() )
+ {
+ if ( pOpenMenu )
+ pOpenMenu->GrabFocus();
+ else
+ GrabFocus();
+ }
+ else if ( pOpenMenu && pOpenMenu->HasFocus() )
+ {
+ GrabFocus();
+ }
+ }
+ else if ( nCode == KEY_RIGHT )
+ {
+ if ( HasFocus() )
+ {
+ if ( pOpenMenu )
+ pOpenMenu->GrabFocus();
+ else if ( pToolBox )
+ pToolBox->GrabFocus();
+ }
+ else if ( pToolBox && pToolBox->HasFocus() )
+ {
+ GrabFocus();
+ }
+ else if ( pOpenMenu && pOpenMenu->HasFocus() )
+ {
+ if ( pToolBox )
+ pToolBox->GrabFocus();
+ else
+ GrabFocus();
+ }
+ }
+}
+
+void NotebookbarTabControl::KeyInput( const KeyEvent& rKEvt )
+{
+ if ( rKEvt.GetKeyCode().IsMod1() )
+ {
+ sal_uInt16 nCode( rKEvt.GetKeyCode().GetCode() );
+ if ( nCode == KEY_RIGHT || nCode == KEY_LEFT )
+ {
+ ArrowStops( nCode );
+ return;
+ }
+ }
+ return NotebookbarTabControlBase::KeyInput( rKEvt );
+}
+
+bool NotebookbarTabControl::EventNotify( NotifyEvent& rNEvt )
+{
+ if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
+ {
+ const vcl::KeyCode& rKey = rNEvt.GetKeyEvent()->GetKeyCode();
+ sal_uInt16 nCode = rKey.GetCode();
+ if ( rKey.IsMod1() && ( nCode == KEY_RIGHT || nCode == KEY_LEFT ) )
+ {
+ ArrowStops( nCode );
+ return true;
+ }
+ }
+ return NotebookbarTabControlBase::EventNotify( rNEvt );
+}
+
void NotebookbarTabControl::StateChanged(StateChangedType nStateChange)
{
if( !m_bInitialized && SfxViewFrame::Current() )