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>
44 lines
1.2 KiB
Markdown
44 lines
1.2 KiB
Markdown
# 010 Divider 分隔线
|
|
|
|
## 用途
|
|
|
|
横向或纵向的细分隔线;横向可在中间放文字;可选旧金色单个菱形装饰。永不获取焦点,装饰不进入无障碍树。
|
|
|
|
## 最小示例
|
|
|
|
```go
|
|
ui.Column(c).Padding(16).Gap(12).Children(func() {
|
|
layout.Divider(c, layout.DividerOptions{Ornament: true})
|
|
layout.Divider(c, layout.DividerOptions{Label: "Chapter II"})
|
|
})
|
|
```
|
|
|
|
签名:`func Divider(c *ui.Context, opts DividerOptions) ui.Element`
|
|
|
|
## 参数
|
|
|
|
| 字段 | 类型 | 默认值 | 含义 |
|
|
| --- | --- | --- | --- |
|
|
| `Vertical` | `bool` | false | 纵向,放在横向行中,高度随行拉伸。 |
|
|
| `Label` | `string` | "" | 横向分隔线中间的文字(衬线 12 DIP,TextMuted)。纵向带文字时 panic。 |
|
|
| `Ornament` | `bool` | false | 线条改用 Ornament 色,并在中间画一个 7 DIP 菱形;有 `Label` 时文字取代菱形。 |
|
|
|
|
## 状态
|
|
|
|
- 默认:1 DIP Border 色细线。
|
|
- 装饰:Ornament 色线与菱形。
|
|
- 无悬停、焦点等交互状态。
|
|
|
|
## 事件
|
|
|
|
无。
|
|
|
|
## 键盘操作
|
|
|
|
不获取焦点,Tab 直接跳过。
|
|
|
|
## 限制
|
|
|
|
- 方向不会根据父级自动判断,需要显式设置 `Vertical`。
|
|
- 纵向不支持文字。
|