From 20c86bd1059b54915190ce2e3dd39206d293aced Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Sat, 22 Apr 2023 23:33:57 +0300 Subject: tdf#153806 a11y Allow opening context menu of fav/recent char w/ keyboard This is similar to commit 1f437264084fd173116965fa4d856aeafdfe7a98 Date: Sun Apr 2 00:36:44 2023 +0300 tdf#153806 a11y: Allow opening context menu in special char dlg using keyboard , but now for the character views in the "Recent Characters" and "Favorite Characters" sections in the special character dialog, and thus addresses this comment from the commit message of the above-mentioned commit: > Adding support for opening the context menu for the > recently used and favorite characters further down > in the special characters dialog is independent of this > and would have to be added separately. Turns out that the position returned by `CommandEvent::GetMousePosPixel` is good for the keyboard case as well, is right in the middle of the char view widget. Change-Id: I9f55b99398d557b19263bf531f6a857d274d3d9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150815 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- sfx2/source/control/charwin.cxx | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx index f80bd30b684d..b94d2bcd1e82 100644 --- a/sfx2/source/control/charwin.cxx +++ b/sfx2/source/control/charwin.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -65,16 +66,10 @@ bool SvxCharView::MouseButtonDown(const MouseEvent& rMEvt) } maMouseClickHdl.Call(this); + return true; } - if (rMEvt.IsRight()) - { - GrabFocus(); - Invalidate(); - createContextMenu(rMEvt.GetPosPixel()); - } - - return true; + return CustomWidgetController::MouseButtonDown(rMEvt); } bool SvxCharView::KeyInput(const KeyEvent& rKEvt) @@ -92,6 +87,19 @@ bool SvxCharView::KeyInput(const KeyEvent& rKEvt) return bRet; } +bool SvxCharView::Command(const CommandEvent& rCommandEvent) +{ + if (rCommandEvent.GetCommand() == CommandEventId::ContextMenu) + { + GrabFocus(); + Invalidate(); + createContextMenu(rCommandEvent.GetMousePosPixel()); + return true; + } + + return weld::CustomWidgetController::Command(rCommandEvent); +} + void SvxCharView::InsertCharToDoc() { if (GetText().isEmpty()) -- cgit