MyGo v0.5.5 returns ui.Element as a checked value handle instead of a
pointer. Migrated with `mygo migrate-ui`, then fixed what the codemod
leaves to review:
- Element nil checks become .Valid(); absent elements are ui.Element{}.
- Input handlers and paint callbacks run outside the build pass, where
elements expire and Context methods are inert: read IsDisabled into a
local during the build, keep a ui.Handle for Focus, use c.Services()
for clipboard access, create ui.Local state during the build.
- Add core.AutoFocus: v0.5.5 records an overlay's opener after its
content builds, so same-frame autofocus lost focus restore on close.
It focuses one frame later; cascader rows defer their focus likewise.
- core.OverlayLayer identifies build passes by the root element, not
c.Now(), which repeats across passes and under the Tester clock.
- Context menus survive the opening press counted as PressedOutside;
split button tooltip no longer reorders its open menu; disabled
menubar rows pass presses to the panel; Form defers blur-started
async checks so the growing message no longer moves Submit away
from the release; Combobox drops its disabled copy now that MyGo
blocks typing under a disabled wrapper (canary flipped to a guard).
- The Tester clock is virtual: tests use Advance/Now instead of
time.Sleep/time.Now and read element state inside the view. The web
mirror advances the clock to wall time before each frame and input.
- AGENTS.md and docs describe the value Element API and the new pin.
Snapshot goldens are darwin-only and were not re-verified here.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1.3 KiB
1.3 KiB
076 Timeline · 时间线
用途
纵向列出事件:时间、标题、内容与状态。标记之间以细线连接,长内容自动换行。状态同时用形状、图标和文字表示,不只依赖颜色。
最小示例
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
data.Timeline(c, []data.TimelineItem{
{Time: "06:00", Title: "Matins sung", Status: data.TimelineDone},
{Time: "09:00", Title: "Relics moved", Content: "From the crypt to the altar.", Status: data.TimelineActive},
{Time: "18:00", Title: "Vespers"},
})
}
ui.Render(view, 400, 300, 1)
参数
func Timeline(c *ui.Context, items []TimelineItem) ui.Element。TimelineItem 字段:Time、Title、Content、Status。
| 字段 | 类型 | 默认值 | 含义 |
|---|---|---|---|
Status |
TimelineStatus |
TimelineDefault |
TimelineDefault(空心菱形)、TimelineDone(勾选图标 + “已完成”)、TimelineActive(实心菱形 + “进行中”)、TimelineWarning(警告图标 + “警告”)、TimelineError(错误图标 + “错误”)。 |
状态
仅展示:默认、完成、进行中、警告、错误。
事件
无。
键盘操作
不获取焦点。
限制
- 仅纵向排列;内容为纯文本。
- 不虚拟化,适合几十条以内的事件。