Elements are now pass-scoped value handles: tests that read bounds after a frame bind a ui.Handle. pixel tells frames apart by the build pass's root, since the Tester clock no longer moves on its own. Fix the regressions the upgrade brought: - Clipboard reads in input handlers go through c.Services(). - MyGo notes an overlay's opener after building it, so AutoFocus inside lost it; pixel.AutoFocus focuses through a Handle, and archtest bans the raw call. Dialogs hand the focus back again. - Elements around a press stay hovered: Tooltip tells a press-given focus by focus arriving under the pointer. - The web host moves the Tester clock with real time, at most 500 ms a call, and gives components the real clock. The gallery's source index also accepts CRLF checkouts. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package navigation
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/icon"
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/input"
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
)
|
|
|
|
type BackForwardOptions struct {
|
|
Disabled bool
|
|
}
|
|
|
|
type BackForwardResult struct {
|
|
Element ui.Element
|
|
// Moved reports a step through the history.
|
|
Moved bool
|
|
}
|
|
|
|
// BackForward walks a router's history with ◀ and ▶.
|
|
func BackForward(c *ui.Context, r *ui.Router, o BackForwardOptions) BackForwardResult {
|
|
k := pixel.K(c)
|
|
res := BackForwardResult{}
|
|
res.Element = ui.Row(c).Gap(k.D(2)).FocusGroup(ui.Horizontal).Role(ui.RoleToolbar).Label(k.Msg("history")).Children(func() {
|
|
back := input.IconButtonOptions{Size: input.Small, Disabled: o.Disabled || !r.CanGoBack()}
|
|
if input.IconButton(c, icon.ChevronLeft, k.Msg("back"), back).Clicked {
|
|
r.Back()
|
|
res.Moved = true
|
|
}
|
|
forth := input.IconButtonOptions{Size: input.Small, Disabled: o.Disabled || !r.CanGoForward()}
|
|
if input.IconButton(c, icon.ChevronRight, k.Msg("forward"), forth).Clicked {
|
|
r.Forward()
|
|
res.Moved = true
|
|
}
|
|
})
|
|
if res.Moved {
|
|
slog.Debug("8bit: history", "path", r.Path())
|
|
}
|
|
return res
|
|
}
|