Add input components 086-105; park focus off disabled controls

This commit is contained in:
ZacharyZhang-NY committed 2026-10-11 20:13:21 -04:00
1 parent 095eab2b4c
commit 03b789f533
34 files changed
+3058 -43

No files matched your search

+9 -3
View File
@@ -92,11 +92,17 @@ 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) })
st = State{Hover: b.Hovered(), Press: b.Pressed(), Focus: b.FocusVisible(), Disabled: b.IsDisabled()}
off := b.IsDisabled()
// MyGo keeps focus and keys on a newly disabled element.
if off && b.Focused() {
c.Root().Focus()
}
st = State{Hover: b.Hovered(), Press: b.Pressed() && !off, Focus: b.FocusVisible(), Disabled: off}
return shell, b, st
}
var hand = MustSprite(`
// Hand is the pointing cursor of focus and menus.
var Hand = MustSprite(`
.eee......
elllleeee.
elllllllle
@@ -116,7 +122,7 @@ func (g Canvas) FocusMark(x, y, w, h int) {
g.ant(rx, ry+j)
g.ant(rx+rw-1, ry+j)
}
g.Sprite(rx-hand.W-1+g.Step(4)%2, y+(h-hand.H)/2, hand, 0, Edge, 1)
g.Sprite(rx-Hand.W-1+g.Step(4)%2, y+(h-Hand.H)/2, Hand, 0, Edge, 1)
}
func (g Canvas) ant(x, y int) {
+2
View File
@@ -12,6 +12,7 @@ var messages = map[Locale]map[string]string{
"remove": "REMOVE", "online": "ONLINE", "away": "AWAY", "busy": "BUSY", "offline": "OFFLINE",
"gold": "GOLD", "silver": "SILVER", "bronze": "BRONZE",
"common": "COMMON", "uncommon": "UNCOMMON", "rare": "RARE", "epic": "EPIC", "legendary": "LEGENDARY",
"hold": "HOLD TO CONFIRM", "del": "DEL", "end": "END", "lives": "+30 LIVES!",
},
Zh: {
"ok": "确定", "cancel": "取消", "yes": "是", "no": "否", "close": "关闭",
@@ -22,6 +23,7 @@ var messages = map[Locale]map[string]string{
"remove": "移除", "online": "在线", "away": "离开", "busy": "忙碌", "offline": "离线",
"gold": "金", "silver": "银", "bronze": "铜",
"common": "普通", "uncommon": "优秀", "rare": "稀有", "epic": "史诗", "legendary": "传说",
"hold": "长按确认", "del": "删", "end": "完", "lives": "命数 +30!",
},
}