diff options
author | Dmitriy Kirakosyan <v-dmkira@microsoft.com> | 2018-11-16 13:17:46 +0300 |
---|---|---|
committer | Dmitriy Kirakosyan <v-dmkira@microsoft.com> | 2018-11-16 13:17:46 +0300 |
commit | 2abba7b56283ec27cd1632b5e4f10dd1dfc56ae1 (patch) | |
tree | e99a8c9ee5cebdaf1c3eb88f2ce9ce04fc3ecd34 /Xwt.Gtk/Xwt.GtkBackend/AccessibleBackend.cs | |
parent | b4da8863782fb04390c3d788147265ab9f7932ca (diff) |
[Gtk][a11y] Use toggle button in comboboxes for setting a11y.
Diffstat (limited to 'Xwt.Gtk/Xwt.GtkBackend/AccessibleBackend.cs')
-rw-r--r-- | Xwt.Gtk/Xwt.GtkBackend/AccessibleBackend.cs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Xwt.Gtk/Xwt.GtkBackend/AccessibleBackend.cs b/Xwt.Gtk/Xwt.GtkBackend/AccessibleBackend.cs index af47e91e..24919768 100644 --- a/Xwt.Gtk/Xwt.GtkBackend/AccessibleBackend.cs +++ b/Xwt.Gtk/Xwt.GtkBackend/AccessibleBackend.cs @@ -24,6 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; +using System.Linq; using Xwt.Accessibility; using Xwt.Backends; @@ -59,10 +60,23 @@ namespace Xwt.GtkBackend public void Initialize (IWidgetBackend parentWidget, IAccessibleEventSink eventSink) { var backend = parentWidget as WidgetBackend; - if (backend is IComboBoxEntryBackend) - Initialize ((backend?.Widget as Gtk.Bin)?.Child, eventSink); - else - Initialize (backend?.Widget, eventSink); + Gtk.Widget nativeWidget = null; + + // Gtk.ComboBox and Gtk.ComboBoxEntry are containers, so we apply a11y properties to their children. + // For Gtk.ComboBoxEntry it is Gtk.Entry, for Gtk.ComboBox -- Gtk.ToggleButton + + if (backend is IComboBoxEntryBackend) { + nativeWidget = (backend?.Widget as Gtk.Bin)?.Child; + } else if (backend is IComboBoxBackend) { + foreach (var child in ((Gtk.Container)backend.Widget).AllChildren) { + if (child is Gtk.ToggleButton) { + nativeWidget = (Gtk.Widget)child; + break; + } + } + } + + Initialize (nativeWidget ?? backend?.Widget, eventSink); } public void Initialize (IPopoverBackend parentPopover, IAccessibleEventSink eventSink) |