include/vcl/settings.hxx              |   11 +++++++++++
 vcl/qt5/QtFrame.cxx                   |    4 ++++
 vcl/source/app/settings.cxx           |   14 ++++++++++++++
 vcl/source/control/combobox.cxx       |   29 +++++++++++++++++++++++++----
 vcl/unx/gtk3/salnativewidgets-gtk.cxx |    4 ++++
 5 files changed, 58 insertions(+), 4 deletions(-)

New commits:
commit 4b53712cccfa48fc7d1f754d6a596204e041d554
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon May 27 14:16:53 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue May 28 06:47:08 2024 +0200

    tdf#160971 gtk: Don't select combobox text on entry selection
    
    In the same way that
    
        Change-Id: I17ce71198ec37cb1735194818bae17d1a5654d89
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Mon May 27 13:35:52 2024 +0200
    
            tdf#160971 qt a11y: Don't select combobox text on entry selection
    
    together with
    
        Change-Id: Ia2c77245049d708885cbd374c20ce1892259329b
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Mon May 27 13:29:39 2024 +0200
    
            tdf#160971 vcl a11y: Make combobox text selection mode style-able
    
    sets the style option to not select combobox text when switching
    between entries in an editable combobox for the Qt-based VCL plugins,
    do the same for the GTK-based VCL plugins, except for putting the
    text cursor at the beginning of the entry text instead of the end,
    as happens when using a native GtkComboBox (see tdf#160971 comment 11).
    
    Since the GTK-based VCL plugins use native GTK widgets
    in most places, the behavior for e.g. the "Font Name"
    combobox in Writer's Formatting toolbar is already like that
    without this change in place and is unaffected by this change
    (even though LO's gtk3 VCL plugin is using a custom combobox
    implementation, see vcl/uiconfig/ui/combobox.ui).
    
    However, the new behavior applies for combobox form
    controls, as can be seen e.g. with the sample doc
    attachment 194376 from tdf#160971.
    
    Change-Id: I5b17efaa167ab49d07f19b3649ff934cf0f34754
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168104
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index 7c2fcc633b77..402a50df6d96 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -209,6 +209,7 @@ enum class ToolbarIconSize
 enum class ComboBoxTextSelectionMode
 {
     SelectText, // select the whole text of the new entry
+    CursorToStart, // don't select text, put text cursor to start of text
     CursorToEnd // don't select text, put text cursor to end of text
 };
 
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 360053e4134d..e8d93f1ea52c 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -384,9 +384,17 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl, LinkParamNone*, 
void)
                 m_pSubEdit->SetSelection(aNewSelection);
                 break;
             }
+            case ComboBoxTextSelectionMode::CursorToStart:
+            {
+                Selection aNewSelection(0, 0);
+                m_pSubEdit->SetSelection(aNewSelection);
+                break;
+            }
             case ComboBoxTextSelectionMode::CursorToEnd:
+            {
                 m_pSubEdit->SetCursorAtLast();
                 break;
+            }
             default:
                 assert(false && "Unhandled ComboBoxTextSelectionMode case");
                 break;
diff --git a/vcl/unx/gtk3/salnativewidgets-gtk.cxx 
b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
index a4e8a82aed28..e02e642bc534 100644
--- a/vcl/unx/gtk3/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
@@ -2579,6 +2579,10 @@ bool GtkSalGraphics::updateSettings(AllSettings& 
rSettings)
     }
 #endif
 
+    // match native GtkComboBox behavior of putting text cursor to start of 
text
+    // without text selection when combobox entry is selected
+    
aStyleSet.SetComboBoxTextSelectionMode(ComboBoxTextSelectionMode::CursorToStart);
+
     // get cursor blink time
     gboolean blink = false;
 
commit 3776874c20b4d4b2b24850c5f21e3b89a7feaaea
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon May 27 13:35:52 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue May 28 06:47:01 2024 +0200

    tdf#160971 qt a11y: Don't select combobox text on entry selection
    
    In order to align the behavior with that of the native
    `QComboBox`, don't select the entry text when selecting
    a different combobox entry, e.g. using the up/down arrow
    keys in the editable combobox for the font name in
    Writer's Formatting toolbar.
    
    In order to achieve that, set the corresponding
    style setting newly introduced in the previous commit,
    
        Change-Id: Ia2c77245049d708885cbd374c20ce1892259329b
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Mon May 27 13:29:39 2024 +0200
    
            tdf#160971 vcl a11y: Make combobox text selection mode style-able
    
    With this in place, the current Orca development version
    (git main as of commit c702b5acb9bd78a5812886a5d1c51409115e3900)
    also no longer announces "selection deleted" every time another entry
    is selected this way when using the qt6 VCL plugin, but only
    announces the text of the newly selected entry.
    
    Change-Id: I17ce71198ec37cb1735194818bae17d1a5654d89
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168103
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index b00ddb92683d..3949650a410c 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -1242,6 +1242,10 @@ void QtFrame::UpdateSettings(AllSettings& rSettings)
     style.SetShadowColor(toColor(pal.color(QPalette::Disabled, 
QPalette::WindowText)));
     style.SetDarkShadowColor(toColor(pal.color(QPalette::Inactive, 
QPalette::WindowText)));
 
+    // match native QComboBox behavior of putting text cursor to end of text
+    // without text selection when combobox entry is selected
+    style.SetComboBoxTextSelectionMode(ComboBoxTextSelectionMode::CursorToEnd);
+
     // Cursor blink interval
     int nFlashTime = QApplication::cursorFlashTime();
     style.SetCursorBlinkTime(nFlashTime != 0 ? nFlashTime / 2 : 
STYLE_CURSOR_NOBLINKTIME);
commit 98f9e9aa6c0dcfdb1ae9ec0ca9a3f6a557ae7396
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon May 27 13:29:39 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue May 28 06:46:55 2024 +0200

    tdf#160971 vcl a11y: Make combobox text selection mode style-able
    
    When selecting an entry of an editable combobox,
    the whole text of the text entry currently gets
    selected.
    
    That matches the behavior observed with a sample
    Windows Forms application.
    
    However, both native GTK and Qt applications
    behave differently and do not select the combobox
    entry text (s. tdf#160971 comment 11 and the
    referenced sample programs and screencasts).
    
    The extra text (un)selection makes the Orca
    screen reader on Linux announce an extra
    "selection deleted" every time
    another entry is selected using the up/down keys
    e.g. in the font selection combobox in Writer's
    Formatting toolbar when using the qt6 VCL plugin
    and the combobox popup is not shown.
    
    Introduce a new style setting to define the
    text selection behavior when switching between
    entries in a ComboBox and take that
    into account in `ComboBox::ImplSelectHdl`.
    
    The default behaviour remains unchanged.
    
    Behavior for the Qt and GTK based VCL plugins
    will be aligned more with the behavior of corresponding
    native widgets in separate upcoming commits.
    
    Change-Id: Ia2c77245049d708885cbd374c20ce1892259329b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168102
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index e21091385bc7..7c2fcc633b77 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -205,6 +205,13 @@ enum class ToolbarIconSize
     Size32       = 3,
 };
 
+/** Text selection behavior when selecting an entry in an editable combobox. */
+enum class ComboBoxTextSelectionMode
+{
+    SelectText, // select the whole text of the new entry
+    CursorToEnd // don't select text, put text cursor to end of text
+};
+
 #define STYLE_CURSOR_NOBLINKTIME    SAL_MAX_UINT64
 
 class VCL_DLLPUBLIC StyleSettings
@@ -627,6 +634,9 @@ public:
     // the default LineWidth for ListBox UI previews (LineStyle, LineDash, 
LineStartEnd). Default is 1.
     static sal_uInt16               GetListBoxPreviewDefaultLineWidth();
 
+    void SetComboBoxTextSelectionMode(ComboBoxTextSelectionMode eMode);
+    ComboBoxTextSelectionMode GetComboBoxTextSelectionMode() const;
+
     // defines if previews which contain potentially transparent objects (e.g. 
the dash/line/LineStartEnd previews and others)
     // use the default transparent visualization background (checkered 
background) as it has got standard in graphic programs nowadays
     void                            SetPreviewUsesCheckeredBackground(bool 
bNew);
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 15079736df29..3a9df910c06d 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -210,6 +210,7 @@ struct ImplStyleData
     sal_uInt16                      mnColorValueSetColumnCount;
     Size                            maListBoxPreviewDefaultLogicSize;
     Size                            maListBoxPreviewDefaultPixelSize;
+    ComboBoxTextSelectionMode       meComboBoxTextSelectionMode;
     bool                            mbPreviewUsesCheckeredBackground;
 
     OUString                        maPersonaHeaderFooter; ///< Cache the 
settings to detect changes.
@@ -500,6 +501,7 @@ ImplStyleData::ImplStyleData() :
     maListBoxPreviewDefaultLogicSize(Size(15, 7)),
 #endif
     maListBoxPreviewDefaultPixelSize(Size(0, 0)), // on-demand calculated in 
GetListBoxPreviewDefaultPixelSize(),
+    meComboBoxTextSelectionMode(ComboBoxTextSelectionMode::SelectText),
     mbPreviewUsesCheckeredBackground(true)
 {
     SetStandardStyles();
@@ -627,6 +629,7 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
     mnColorValueSetColumnCount(rData.mnColorValueSetColumnCount),
     maListBoxPreviewDefaultLogicSize(rData.maListBoxPreviewDefaultLogicSize),
     maListBoxPreviewDefaultPixelSize(rData.maListBoxPreviewDefaultPixelSize),
+    meComboBoxTextSelectionMode(rData.meComboBoxTextSelectionMode),
     mbPreviewUsesCheckeredBackground(rData.mbPreviewUsesCheckeredBackground),
     maPersonaHeaderFooter( rData.maPersonaHeaderFooter ),
     maPersonaHeaderBitmap( rData.maPersonaHeaderBitmap ),
@@ -2277,6 +2280,17 @@ StyleSettings::GetListBoxPreviewDefaultLineWidth()
     return 1;
 }
 
+void StyleSettings::SetComboBoxTextSelectionMode(
+    ComboBoxTextSelectionMode eMode)
+{
+    mxData->meComboBoxTextSelectionMode = eMode;
+}
+
+ComboBoxTextSelectionMode StyleSettings::GetComboBoxTextSelectionMode() const
+{
+    return mxData->meComboBoxTextSelectionMode;
+}
+
 void
 StyleSettings::SetPreviewUsesCheckeredBackground(bool bNew)
 {
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index f4327ac77024..360053e4134d 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -374,10 +374,23 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl, LinkParamNone*, 
void)
 
         m_pSubEdit->SetText( aText );
 
-        Selection aNewSelection( 0, aText.getLength() );
-        if (IsMultiSelectionEnabled())
-            aNewSelection.Min() = aText.getLength();
-        m_pSubEdit->SetSelection( aNewSelection );
+        switch 
(GetSettings().GetStyleSettings().GetComboBoxTextSelectionMode())
+        {
+            case ComboBoxTextSelectionMode::SelectText:
+            {
+                Selection aNewSelection(0, aText.getLength());
+                if (IsMultiSelectionEnabled())
+                    aNewSelection.Min() = aText.getLength();
+                m_pSubEdit->SetSelection(aNewSelection);
+                break;
+            }
+            case ComboBoxTextSelectionMode::CursorToEnd:
+                m_pSubEdit->SetCursorAtLast();
+                break;
+            default:
+                assert(false && "Unhandled ComboBoxTextSelectionMode case");
+                break;
+        }
 
         bCallSelect = true;
     }

Reply via email to