Kaydet (Commit) cb834ae5 authored tarafından Jim Raykowski's avatar Jim Raykowski

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: 's avatarJim Raykowski <raykowj@gmail.com>
üst 63901334
...@@ -27,6 +27,8 @@ public: ...@@ -27,6 +27,8 @@ public:
NotebookbarTabControl( Window* pParent ); NotebookbarTabControl( Window* pParent );
~NotebookbarTabControl() override; ~NotebookbarTabControl() override;
virtual void KeyInput( const KeyEvent& rKEvt ) override;
virtual bool EventNotify( NotifyEvent& rNEvt ) override;
virtual void StateChanged(StateChangedType nStateChange) override; virtual void StateChanged(StateChangedType nStateChange) override;
virtual Size calculateRequisition() const override; virtual Size calculateRequisition() const override;
...@@ -36,6 +38,8 @@ private: ...@@ -36,6 +38,8 @@ private:
const OUString& aModuleName, const OUString& aModuleName,
ToolBox* pShortcuts ToolBox* pShortcuts
); );
void ArrowStops( sal_uInt16 nCode );
DECL_LINK(OpenNotebookbarPopupMenu, NotebookBar*, void); DECL_LINK(OpenNotebookbarPopupMenu, NotebookBar*, void);
css::uno::Reference<css::ui::XUIConfigurationListener> m_pListener; css::uno::Reference<css::ui::XUIConfigurationListener> m_pListener;
......
...@@ -201,6 +201,7 @@ public: ...@@ -201,6 +201,7 @@ public:
void SetIconClickHdl( Link<NotebookBar*, void> aHdl ); void SetIconClickHdl( Link<NotebookBar*, void> aHdl );
void SetToolBox( ToolBox* pToolBox ); void SetToolBox( ToolBox* pToolBox );
ToolBox* GetToolBox() { return m_pShortcuts; } ToolBox* GetToolBox() { return m_pShortcuts; }
PushButton* GetOpenMenu() { return m_pOpenMenu; }
virtual sal_uInt16 GetPageId( const Point& rPos ) const override; virtual sal_uInt16 GetPageId( const Point& rPos ) const override;
virtual void SelectTabPage( sal_uInt16 nPageId ) override; virtual void SelectTabPage( sal_uInt16 nPageId ) override;
......
...@@ -126,6 +126,20 @@ public: ...@@ -126,6 +126,20 @@ public:
mbUseDefaultButtonSize = false; mbUseDefaultButtonSize = false;
SetToolboxButtonSize(ToolBoxButtonSize::Small); 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 ) NotebookbarTabControl::NotebookbarTabControl( Window* pParent )
...@@ -139,6 +153,84 @@ NotebookbarTabControl::~NotebookbarTabControl() ...@@ -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) void NotebookbarTabControl::StateChanged(StateChangedType nStateChange)
{ {
if( !m_bInitialized && SfxViewFrame::Current() ) if( !m_bInitialized && SfxViewFrame::Current() )
......
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