Add feedback components 106-130; inert scope, focus return, two-step deploy

This commit is contained in:
ZacharyZhang-NY committed 2026-10-11 20:58:30 -04:00
1 parent bce416182e
commit bd3877e1b1
87 files changed
+2492 -147

No files matched your search

+20 -5
View File
@@ -92,15 +92,30 @@ type State struct{ Hover, Press, Focus, Disabled bool }
func Shell(c *ui.Context, base func() *ui.Element) (shell, b *ui.Element, st State) {
shell = ui.Box(c)
shell.Children(func() { b = base().Fill().FocusRing(false) })
off := b.IsDisabled()
// MyGo keeps focus and keys on a newly disabled element.
if off && b.Focused() {
c.Root().Focus()
own, inert := b.IsDisabled(), current(c).cur.Inert
if inert {
b.Disabled(true)
}
st = State{Hover: b.Hovered(), Press: b.Pressed() && !off, Focus: b.FocusVisible(), Disabled: off}
off := own || inert
// MyGo keeps focus and keys on a newly disabled element.
parked := ui.Local(b, parkKey{}, func() bool { return false })
switch {
case off && b.Focused():
c.Root().Focus()
*parked = true
case !off && *parked:
// Focus comes back unless something else took it.
if root := c.Root(); root.Focused() || !root.FocusWithin() {
b.Focus()
}
*parked = false
}
st = State{Hover: b.Hovered(), Press: b.Pressed() && !off, Focus: b.FocusVisible(), Disabled: own}
return shell, b, st
}
type parkKey struct{}
// Hand is the pointing cursor of focus and menus.
var Hand = MustSprite(`
.eee......