aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-10-26 06:00:28 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-10-26 11:42:30 +0200
commitecea423005dacfb051b9e3bec843b581c923e5a3 (patch)
tree84901937ca1a35e77f5255e797e1793a5b080e23 /ui
parentui: allow (Shift+)Tab to move focus to sibling controls in RichEdit (diff)
downloadwireguard-windows-ecea423005dacfb051b9e3bec843b581c923e5a3.tar.xz
wireguard-windows-ecea423005dacfb051b9e3bec843b581c923e5a3.zip
ui: fix configuration editbox accessibility name
RichEdit controls without a label report their name as "RichEdit Control" and the Dynamic Annotation cannot override this. Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'ui')
-rw-r--r--ui/editdialog.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/ui/editdialog.go b/ui/editdialog.go
index 191b3330..4d25dd79 100644
--- a/ui/editdialog.go
+++ b/ui/editdialog.go
@@ -10,6 +10,8 @@ import (
"strings"
"github.com/lxn/walk"
+ "github.com/lxn/win"
+ "golang.org/x/sys/windows"
"golang.zx2c4.com/wireguard/windows/conf"
"golang.zx2c4.com/wireguard/windows/manager"
@@ -114,8 +116,6 @@ func newEditDialog(owner walk.Form, tunnel *manager.Tunnel) (*EditDialog, error)
return nil, err
}
layout.SetRange(dlg.syntaxEdit, walk.Rectangle{0, 2, 2, 1})
- // TODO: This doesn't work - RTF control overrides us with "RichEdit Control".
- dlg.syntaxEdit.Accessibility().SetName("Configuration")
buttonsContainer, err := walk.NewComposite(dlg)
if err != nil {
@@ -155,6 +155,20 @@ func newEditDialog(owner walk.Form, tunnel *manager.Tunnel) (*EditDialog, error)
dlg.syntaxEdit.BlockUntunneledTrafficStateChanged().Attach(dlg.onBlockUntunneledTrafficStateChanged)
dlg.syntaxEdit.SetText(dlg.config.ToWgQuick())
+ // Insert a dummy label immediately preceding syntaxEdit to have screen readers read it.
+ // Otherwise they fallback to "RichEdit Control".
+ syntaxEditWnd := dlg.syntaxEdit.Handle()
+ parentWnd := win.GetParent(syntaxEditWnd)
+ labelWnd := win.CreateWindowEx(0,
+ windows.StringToUTF16Ptr("STATIC"), windows.StringToUTF16Ptr("&Configuration:"),
+ win.WS_CHILD|win.WS_GROUP|win.SS_LEFT, 0, 0, 0, 0,
+ parentWnd, win.HMENU(^uintptr(0)), win.HINSTANCE(win.GetWindowLongPtr(parentWnd, win.GWLP_HINSTANCE)), nil)
+ prevWnd := win.GetWindow(syntaxEditWnd, win.GW_HWNDPREV)
+ nextWnd := win.GetWindow(syntaxEditWnd, win.GW_HWNDNEXT)
+ win.SetWindowPos(labelWnd, prevWnd, 0, 0, 0, 0, win.SWP_NOSIZE|win.SWP_NOMOVE)
+ win.SetWindowPos(syntaxEditWnd, labelWnd, 0, 0, 0, 0, win.SWP_NOSIZE|win.SWP_NOMOVE)
+ win.SetWindowPos(nextWnd, syntaxEditWnd, 0, 0, 0, 0, win.SWP_NOSIZE|win.SWP_NOMOVE)
+
if tunnel != nil {
dlg.Starting().Attach(func() {
dlg.syntaxEdit.SetFocus()