diff options
author | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-06-09 08:51:50 +0530 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-06-09 12:42:07 +0000 |
commit | 40ca34340e4b387bdce92b86cb572556c5437c7d (patch) | |
tree | 9557a89649e14b3a12735b4996069eee7bc294a3 | |
parent | 6363f7277fc9efc86ac699d0ea973021ed2b652c (diff) |
tdf#100260 Template Manager: Cannot open context menu without mouse
Change-Id: I900cc79e2834c1942840ee9fb1a8ab680b646c92
Reviewed-on: https://gerrit.libreoffice.org/26082
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r-- | include/sfx2/templateabstractview.hxx | 4 | ||||
-rw-r--r-- | include/sfx2/templatedlg.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/templateabstractview.cxx | 24 | ||||
-rw-r--r-- | sfx2/source/control/templatesearchview.cxx | 33 | ||||
-rw-r--r-- | sfx2/source/dialog/backingwindow.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/dialog/backingwindow.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/inc/templatesearchview.hxx | 6 |
8 files changed, 64 insertions, 17 deletions
diff --git a/include/sfx2/templateabstractview.hxx b/include/sfx2/templateabstractview.hxx index a220f5a5edaa..79ec353792e1 100644 --- a/include/sfx2/templateabstractview.hxx +++ b/include/sfx2/templateabstractview.hxx @@ -97,7 +97,7 @@ public: void setOpenRegionHdl(const Link<void*,void> &rLink); - void setRightClickHdl(const Link<ThumbnailViewItem*,void> &rLink); + void setCreateContextMenuHdl(const Link<ThumbnailViewItem*,void> &rLink); void setOpenTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink); @@ -140,7 +140,7 @@ protected: Point maPosition; Link<void*,void> maOpenRegionHdl; - Link<ThumbnailViewItem*,void> maRightClickHdl; + Link<ThumbnailViewItem*,void> maCreateContextMenuHdl; Link<ThumbnailViewItem*,void> maOpenTemplateHdl; Link<ThumbnailViewItem*,void> maEditTemplateHdl; Link<ThumbnailViewItem*,void> maDeleteTemplateHdl; diff --git a/include/sfx2/templatedlg.hxx b/include/sfx2/templatedlg.hxx index 26e6959db8d6..3b7f2b914583 100644 --- a/include/sfx2/templatedlg.hxx +++ b/include/sfx2/templatedlg.hxx @@ -81,7 +81,7 @@ protected: DECL_LINK_TYPED(DefaultTemplateMenuSelectHdl, Menu*, bool); DECL_LINK_TYPED(OpenRegionHdl, void*, void); - DECL_LINK_TYPED(RightClickHdl, ThumbnailViewItem*, void); + DECL_LINK_TYPED(CreateContextMenuHdl, ThumbnailViewItem*, void); DECL_LINK_TYPED(OpenTemplateHdl, ThumbnailViewItem*, void); DECL_LINK_TYPED(EditTemplateHdl, ThumbnailViewItem*, void); DECL_LINK_TYPED(DeleteTemplateHdl, ThumbnailViewItem*, void); diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index e19621d200ef..536acdf425e5 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -167,7 +167,7 @@ void TemplateAbstractView::MouseButtonDown( const MouseEvent& rMEvt ) if(pViewItem) { maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem); - maRightClickHdl.Call(pItem); + maCreateContextMenuHdl.Call(pItem); } } @@ -193,6 +193,24 @@ void TemplateAbstractView::KeyInput( const KeyEvent& rKEvt ) Invalidate(); return; } + else if(aKeyCode == (KEY_SHIFT | KEY_F10 )) + { + for (ThumbnailViewItem* pItem : mFilteredItemList) + { + //create context menu for the first selected item + if (pItem->isSelected()) + { + deselectItems(); + pItem->setSelection(true); + maItemStateHdl.Call(pItem); + Rectangle aRect = pItem->getDrawArea(); + maPosition = aRect.Center(); + maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem); + maCreateContextMenuHdl.Call(pItem); + break; + } + } + } ThumbnailView::KeyInput(rKEvt); } @@ -203,9 +221,9 @@ void TemplateAbstractView::setOpenRegionHdl(const Link<void*,void> &rLink) maOpenRegionHdl = rLink; } -void TemplateAbstractView::setRightClickHdl(const Link<ThumbnailViewItem*,void> &rLink) +void TemplateAbstractView::setCreateContextMenuHdl(const Link<ThumbnailViewItem*,void> &rLink) { - maRightClickHdl = rLink; + maCreateContextMenuHdl = rLink; } void TemplateAbstractView::setOpenTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink) diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx index ab2f48960b14..f30c98d71e07 100644 --- a/sfx2/source/control/templatesearchview.cxx +++ b/sfx2/source/control/templatesearchview.cxx @@ -46,13 +46,40 @@ void TemplateSearchView::MouseButtonDown( const MouseEvent& rMEvt ) if(pViewItem) { maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem); - maRightClickHdl.Call(pItem); + maCreateContextMenuHdl.Call(pItem); } } ThumbnailView::MouseButtonDown(rMEvt); } + +void TemplateSearchView::KeyInput( const KeyEvent& rKEvt ) +{ + vcl::KeyCode aKeyCode = rKEvt.GetKeyCode(); + + if(aKeyCode == (KEY_SHIFT | KEY_F10 )) + { + for (ThumbnailViewItem* pItem : mFilteredItemList) + { + //create context menu for the first selected item + if (pItem->isSelected()) + { + deselectItems(); + pItem->setSelection(true); + maItemStateHdl.Call(pItem); + Rectangle aRect = pItem->getDrawArea(); + maPosition = aRect.Center(); + maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem); + maCreateContextMenuHdl.Call(pItem); + break; + } + } + } + + ThumbnailView::KeyInput(rKEvt); +} + void TemplateSearchView::createContextMenu( const bool bIsDefault) { std::unique_ptr<PopupMenu> pItemMenu(new PopupMenu); @@ -98,9 +125,9 @@ IMPL_LINK_TYPED(TemplateSearchView, ContextMenuSelectHdl, Menu*, pMenu, bool) return false; } -void TemplateSearchView::setRightClickHdl(const Link<ThumbnailViewItem*,void> &rLink) +void TemplateSearchView::setCreateContextMenuHdl(const Link<ThumbnailViewItem*,void> &rLink) { - maRightClickHdl = rLink; + maCreateContextMenuHdl = rLink; } void TemplateSearchView::setOpenTemplateHdl(const Link<ThumbnailViewItem*, void> &rLink) diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 20e97a7ae2a9..3c4510672765 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -262,7 +262,7 @@ void BackingWindow::initControls() mpTemplateButton->SetMenuMode( MENUBUTTON_MENUMODE_TIMED ); //set handlers - mpLocalView->setRightClickHdl(LINK(this, BackingWindow, RightClickHdl)); + mpLocalView->setCreateContextMenuHdl(LINK(this, BackingWindow, CreateContextMenuHdl)); mpLocalView->setOpenTemplateHdl(LINK(this, BackingWindow, OpenTemplateHdl)); mpLocalView->setEditTemplateHdl(LINK(this, BackingWindow, EditTemplateHdl)); @@ -625,7 +625,7 @@ IMPL_LINK_TYPED( BackingWindow, MenuSelectHdl, MenuButton*, pButton, void ) mpLocalView->GrabFocus(); } -IMPL_LINK_TYPED(BackingWindow, RightClickHdl, ThumbnailViewItem*, pItem, void) +IMPL_LINK_TYPED(BackingWindow, CreateContextMenuHdl, ThumbnailViewItem*, pItem, void) { const TemplateViewItem *pViewItem = dynamic_cast<TemplateViewItem*>(pItem); diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx index 5b5194a106ef..199302f2e500 100644 --- a/sfx2/source/dialog/backingwindow.hxx +++ b/sfx2/source/dialog/backingwindow.hxx @@ -103,7 +103,7 @@ class BackingWindow : public vcl::Window, public VclBuilderContainer DECL_LINK_TYPED(ClickHdl, Button*, void); DECL_LINK_TYPED(MenuSelectHdl, MenuButton*, void); DECL_LINK_TYPED(ExtLinkClickHdl, Button*, void); - DECL_LINK_TYPED(RightClickHdl, ThumbnailViewItem*, void); + DECL_LINK_TYPED(CreateContextMenuHdl, ThumbnailViewItem*, void); DECL_LINK_TYPED(OpenTemplateHdl, ThumbnailViewItem*, void); DECL_LINK_TYPED(EditTemplateHdl, ThumbnailViewItem*, void); diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 77e78f09c97e..67b338cb8027 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -220,7 +220,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent) TEMPLATE_ITEM_PADDING); mpLocalView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVItemStateHdl)); - mpLocalView->setRightClickHdl(LINK(this,SfxTemplateManagerDlg, RightClickHdl)); + mpLocalView->setCreateContextMenuHdl(LINK(this,SfxTemplateManagerDlg, CreateContextMenuHdl)); mpLocalView->setOpenRegionHdl(LINK(this,SfxTemplateManagerDlg, OpenRegionHdl)); mpLocalView->setOpenTemplateHdl(LINK(this,SfxTemplateManagerDlg, OpenTemplateHdl)); mpLocalView->setEditTemplateHdl(LINK(this,SfxTemplateManagerDlg, EditTemplateHdl)); @@ -245,7 +245,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent) TEMPLATE_ITEM_PADDING); mpSearchView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVItemStateHdl)); - mpSearchView->setRightClickHdl(LINK(this,SfxTemplateManagerDlg, RightClickHdl)); + mpSearchView->setCreateContextMenuHdl(LINK(this,SfxTemplateManagerDlg, CreateContextMenuHdl)); mpSearchView->setOpenTemplateHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl)); mpSearchView->setEditTemplateHdl(LINK(this,SfxTemplateManagerDlg, EditTemplateHdl)); mpSearchView->setDeleteTemplateHdl(LINK(this,SfxTemplateManagerDlg, DeleteTemplateHdl)); @@ -755,7 +755,7 @@ IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, OpenRegionHdl, void*, void) mpActionBar->Show(); } -IMPL_LINK_TYPED(SfxTemplateManagerDlg, RightClickHdl, ThumbnailViewItem*, pItem, void) +IMPL_LINK_TYPED(SfxTemplateManagerDlg, CreateContextMenuHdl, ThumbnailViewItem*, pItem, void) { const TemplateViewItem *pViewItem = dynamic_cast<TemplateViewItem*>(pItem); diff --git a/sfx2/source/inc/templatesearchview.hxx b/sfx2/source/inc/templatesearchview.hxx index e6f75f4bb422..1dda8c595170 100644 --- a/sfx2/source/inc/templatesearchview.hxx +++ b/sfx2/source/inc/templatesearchview.hxx @@ -25,7 +25,7 @@ public: DECL_LINK_TYPED(ContextMenuSelectHdl, Menu*, bool); - void setRightClickHdl(const Link<ThumbnailViewItem*,void> &rLink); + void setCreateContextMenuHdl(const Link<ThumbnailViewItem*,void> &rLink); void setEditTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink); @@ -46,13 +46,15 @@ protected: virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + protected: TemplateViewItem *maSelectedItem; Point maPosition; Link<ThumbnailViewItem*, void> maOpenTemplateHdl; - Link<ThumbnailViewItem*, void> maRightClickHdl; + Link<ThumbnailViewItem*, void> maCreateContextMenuHdl; Link<ThumbnailViewItem*,void> maEditTemplateHdl; Link<ThumbnailViewItem*,void> maDeleteTemplateHdl; Link<ThumbnailViewItem*,void> maDefaultTemplateHdl; |