summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-02-25 17:27:15 +0100
committerAlexander Neumann <alexander.neumann@picos-software.com>2019-02-25 17:27:15 +0100
commit431cd50ed4202ecf889258f94c887182050c806a (patch)
treea307e0d0f0ef7a1ff9f0c0984578b83f1cbbee5f
parentMissed a file in some previous commit (diff)
downloadwireguard-windows-431cd50ed4202ecf889258f94c887182050c806a.tar.xz
wireguard-windows-431cd50ed4202ecf889258f94c887182050c806a.zip
FormBase: Try to fix scrolling problems with initially focused descendant
-rw-r--r--form.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/form.go b/form.go
index 52084404..dd8bad4d 100644
--- a/form.go
+++ b/form.go
@@ -396,6 +396,21 @@ func (fb *FormBase) Run() int {
fb.SetBounds(fb.Bounds())
+ // Some widgets perform weird scrolling stunts, when initially focused.
+ // We try to fix that here and hope for the best.
+ if hwnd := win.GetFocus(); hwnd != 0 {
+ if window := windowFromHandle(hwnd); window != nil {
+ fb.ForEachDescendant(func(widget Widget) bool {
+ if widget.Handle() != hwnd && widget.SetFocus() == nil {
+ window.SetFocus()
+ return false
+ }
+
+ return true
+ })
+ }
+ }
+
var msg win.MSG
if processMessageProc != 0 {