Root Focus Is Too Sticky
Closed this issue · 0 comments
justledbetter commented
Thank you for #81, this definitely gets things working more closely to the way I was hoping to use it!
There's one slight issue with the resulting workflow, though - Popups are inconsistently focused when opened. Modified the example code to demonstrate the issue. (Is this related to the discussion we had over programmatically raising nucular.Window objects by restacking the window queue?)
package main
import (
"image"
"github.com/aarzilli/nucular"
"github.com/aarzilli/nucular/rect"
"github.com/aarzilli/nucular/style"
)
func main() {
w := nucular.NewMasterWindowSize(
nucular.WindowScalable,
"Test window",
image.Point{640, 480},
func(w *nucular.Window) {
w.Row(64).Dynamic(5)
w.Row(64).Dynamic(5)
w.Spacing(1)
if w.ButtonText("I Am Broken") {
w.Master().PopupOpen(
"Root Window Button",
nucular.WindowClosable|nucular.WindowBorder|nucular.WindowTitle|nucular.WindowNonmodal,
rect.Rect{X: 200, Y: 200, W: 300, H: 100},
false,
func(w *nucular.Window) {
w.Row(0).Dynamic(1)
w.Label("This new window does NOT have focus", "LC")
},
)
}
},
)
w.SetStyle(style.FromTheme(style.WhiteTheme, 1.0))
w.PopupOpen(
"Sub Window",
nucular.WindowNonmodal|nucular.WindowMovable|nucular.WindowScalable|
nucular.WindowTitle|nucular.WindowBorder|nucular.WindowClosable,
rect.Rect{X: 50, Y: 50, W: 200, H: 100},
false,
func(w *nucular.Window) {
w.Row(0).Dynamic(1)
if w.ButtonText("I Work") { // Works as expected
w.Master().PopupOpen(
"Subwindow Button",
nucular.WindowClosable|nucular.WindowBorder|nucular.WindowTitle|nucular.WindowNonmodal,
rect.Rect{X: 300, Y: 300, W: 300, H: 100},
false,
func(w *nucular.Window) {
w.Row(0).Dynamic(1)
w.Label("This new window has focus", "LC")
},
)
}
},
)
w.Main()
}