diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2023-04-01 23:36:02 +0300 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-04-03 17:00:55 +0200 |
commit | fa7fc141e49bf1a5e1fc30645d559c19205d76a7 (patch) | |
tree | e33fbd7a4652c6a70741a14d223f1110133bc61a | |
parent | d1f5b3c5cb226fd5f58fe2cdc8be9d1330fad6a2 (diff) |
tdf#153806 a11y: Insert special char + close dialog on return key
As discussed in tdf#153806, insert the currently selected
character from the special characters dialog and close
the dialog when the return key is pressed on the
table of characters (either showing all characters
or just the search result).
Something similar should probably be done when the return
key is pressed with one of the recent characters or
favorite characters in the dialog having focus, but
that needs to be handled separately, possibly along
with the other remaining suggestions to improve keyboard
handling in the special characters dialog as discussed in
tdf#153806.
Change-Id: Iccc19e4808ddf6f15c32710f9bea931e46b046bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149920
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r-- | cui/source/dialogs/cuicharmap.cxx | 8 | ||||
-rw-r--r-- | include/cui/cuicharmap.hxx | 1 | ||||
-rw-r--r-- | include/svx/charmap.hxx | 4 | ||||
-rw-r--r-- | svx/source/dialog/charmap.cxx | 4 | ||||
-rw-r--r-- | svx/source/dialog/searchcharmap.cxx | 3 |
5 files changed, 17 insertions, 3 deletions
diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx index 7bcbc463c26f..81594684d5ed 100644 --- a/cui/source/dialogs/cuicharmap.cxx +++ b/cui/source/dialogs/cuicharmap.cxx @@ -509,12 +509,14 @@ void SvxCharacterMap::init() m_xOKBtn->show(); m_xShowSet->SetDoubleClickHdl( LINK( this, SvxCharacterMap, CharDoubleClickHdl ) ); + m_xShowSet->SetReturnKeyPressHdl(LINK(this, SvxCharacterMap, ReturnKeypressOnCharHdl)); m_xShowSet->SetSelectHdl( LINK( this, SvxCharacterMap, CharSelectHdl ) ); m_xShowSet->SetHighlightHdl( LINK( this, SvxCharacterMap, CharHighlightHdl ) ); m_xShowSet->SetPreSelectHdl( LINK( this, SvxCharacterMap, CharPreSelectHdl ) ); m_xShowSet->SetFavClickHdl( LINK( this, SvxCharacterMap, FavClickHdl ) ); m_xSearchSet->SetDoubleClickHdl( LINK( this, SvxCharacterMap, CharDoubleClickHdl ) ); + m_xSearchSet->SetReturnKeyPressHdl(LINK(this, SvxCharacterMap, ReturnKeypressOnCharHdl)); m_xSearchSet->SetSelectHdl( LINK( this, SvxCharacterMap, CharSelectHdl ) ); m_xSearchSet->SetHighlightHdl( LINK( this, SvxCharacterMap, SearchCharHighlightHdl ) ); m_xSearchSet->SetPreSelectHdl( LINK( this, SvxCharacterMap, CharPreSelectHdl ) ); @@ -941,6 +943,12 @@ IMPL_LINK_NOARG(SvxCharacterMap, CharSelectHdl, SvxShowCharSet*, void) m_xOKBtn->set_sensitive(true); } +IMPL_LINK(SvxCharacterMap, ReturnKeypressOnCharHdl, SvxShowCharSet*, pCharSet, void) +{ + insertSelectedCharacter(pCharSet); + m_xDialog->response(RET_OK); +} + IMPL_LINK_NOARG(SvxCharacterMap, InsertClickHdl, weld::Button&, void) { OUString sChar = m_aShowChar.GetText(); diff --git a/include/cui/cuicharmap.hxx b/include/cui/cuicharmap.hxx index 351382d71f53..431ce6dc30f5 100644 --- a/include/cui/cuicharmap.hxx +++ b/include/cui/cuicharmap.hxx @@ -129,6 +129,7 @@ private: DECL_DLLPRIVATE_LINK(CharSelectHdl, SvxShowCharSet*, void); DECL_DLLPRIVATE_LINK(CharHighlightHdl, SvxShowCharSet*, void); DECL_DLLPRIVATE_LINK(CharPreSelectHdl, SvxShowCharSet*, void); + DECL_DLLPRIVATE_LINK(ReturnKeypressOnCharHdl, SvxShowCharSet*, void); DECL_DLLPRIVATE_LINK(FavClickHdl, SvxShowCharSet*, void); DECL_DLLPRIVATE_LINK(SearchCharHighlightHdl, SvxShowCharSet*, void); DECL_DLLPRIVATE_LINK(DecimalCodeChangeHdl, weld::Entry&, void); diff --git a/include/svx/charmap.hxx b/include/svx/charmap.hxx index 6c84a53a0d9a..5f0bfe6ffdee 100644 --- a/include/svx/charmap.hxx +++ b/include/svx/charmap.hxx @@ -69,6 +69,7 @@ public: void createContextMenu(); void SetDoubleClickHdl( const Link<SvxShowCharSet*,void>& rLink ) { aDoubleClkHdl = rLink; } + void SetReturnKeyPressHdl( const Link<SvxShowCharSet*,void>& rLink ) { m_aReturnKeypressHdl = rLink; } void SetSelectHdl( const Link<SvxShowCharSet*,void>& rHdl ) { aSelectHdl = rHdl; } void SetHighlightHdl( const Link<SvxShowCharSet*,void>& rHdl ) { aHighHdl = rHdl; } void SetPreSelectHdl( const Link<SvxShowCharSet*,void>& rHdl ) { aPreSelectHdl = rHdl; } @@ -110,7 +111,6 @@ private: virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; virtual void GetFocus() override; virtual void LoseFocus() override; - virtual bool KeyInput(const KeyEvent&) override; virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override; virtual FactoryFunction GetUITestFactory() const override; @@ -119,6 +119,7 @@ protected: typedef std::map<sal_Int32, std::shared_ptr<svx::SvxShowCharSetItem> > ItemsMap; ItemsMap m_aItems; Link<SvxShowCharSet*,void> aDoubleClkHdl; + Link<SvxShowCharSet*,void> m_aReturnKeypressHdl; Link<SvxShowCharSet*,void> aSelectHdl; Link<SvxShowCharSet*,void> aFavClickHdl; Link<SvxShowCharSet*,void> aHighHdl; @@ -146,6 +147,7 @@ protected: protected: + virtual bool KeyInput(const KeyEvent&) override; virtual void DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1, int n2); void InitSettings(vcl::RenderContext& rRenderContext); // abstraction layers are: Unicode<->MapIndex<->Pixel diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx index ead099007295..90bb03081af9 100644 --- a/svx/source/dialog/charmap.cxx +++ b/svx/source/dialog/charmap.cxx @@ -397,6 +397,9 @@ bool SvxShowCharSet::KeyInput(const KeyEvent& rKEvt) switch (aCode.GetCode()) { + case KEY_RETURN: + m_aReturnKeypressHdl.Call(this); + return true; case KEY_SPACE: aDoubleClkHdl.Call(this); return true; @@ -426,7 +429,6 @@ bool SvxShowCharSet::KeyInput(const KeyEvent& rKEvt) break; case KEY_TAB: // some fonts have a character at these unicode control codes case KEY_ESCAPE: - case KEY_RETURN: tmpSelected = - 1; // mark as invalid bRet = false; break; diff --git a/svx/source/dialog/searchcharmap.cxx b/svx/source/dialog/searchcharmap.cxx index 8303c5378d16..dc3ef7bcecab 100644 --- a/svx/source/dialog/searchcharmap.cxx +++ b/svx/source/dialog/searchcharmap.cxx @@ -63,6 +63,8 @@ bool SvxSearchCharSet::KeyInput(const KeyEvent& rKEvt) switch (aCode.GetCode()) { + case KEY_RETURN: + return SvxShowCharSet::KeyInput(rKEvt); case KEY_SPACE: aDoubleClkHdl.Call(this); return true; @@ -92,7 +94,6 @@ bool SvxSearchCharSet::KeyInput(const KeyEvent& rKEvt) break; case KEY_TAB: // some fonts have a character at these unicode control codes case KEY_ESCAPE: - case KEY_RETURN: bRet = false; tmpSelected = - 1; // mark as invalid break; |