Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Writing in a note, a name, the search or a mockup's field no longer opens Present, picks a tool or takes the hand: the
letters, the space and, while presenting, the arrows are the field's alone.
- With the cursor in a field, Ctrl+Z, Ctrl+Shift+Z and Ctrl+A undo, redo and select its text, no longer the project's
last change and the board's screens.
- On Linux, a window wider or taller than 4096 pixels, as on a 5K screen, no longer closes gockup.
- The applications menu shows **Gockup**, with a capital G, like the other apps in it.

## [0.6.0] - 2026-12-03
Expand Down
3 changes: 2 additions & 1 deletion DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ a model lays it out on purpose with `list_places` and `place_screens`.
- Columns keep twice the frames' gap apart (256dp for 1280 wide screens), rows a fifth of the height
(160dp for 800 tall), so steps read apart from states and every title fits.
- Ctrl+Z undoes and Ctrl+Shift+Z redoes, back to when the project was opened: screens, components,
places and images, a deleted image's bytes included while the history still holds it.
places and images, a deleted image's bytes included while the history still holds it. With the cursor in a
text field, they and Ctrl+A are the text's, as the letters and the space are: no shortcut of the board's.

## Notes

Expand Down
20 changes: 13 additions & 7 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2053,18 +2053,24 @@ func (a *studio) notices(b *strings.Builder) {
}

func (a *studio) layoutCanvas(gtx layout.Context) layout.Dimensions {
// no Focus, like the board's tool keys: Ctrl+Z, Ctrl+Shift+Z and
// Ctrl+Alt+T (Figma's tidy up) work wherever the focus is
for {
ev, ok := gtx.Event(
a.board.writing = a.writing(gtx)
// no Focus, like the board's tool keys: they work wherever the focus is, but
// for the ones a text field answers itself
keys := []event.Filter{
key.Filter{Name: "T", Required: key.ModShortcut | key.ModAlt},
key.Filter{Name: "D", Required: key.ModShortcut},
key.Filter{Name: "E", Required: key.ModShortcut | key.ModShift},
}
if !a.board.writing {
keys = append(keys,
key.Filter{Name: "Z", Required: key.ModShortcut, Optional: key.ModShift},
key.Filter{Name: "T", Required: key.ModShortcut | key.ModAlt},
key.Filter{Name: "D", Required: key.ModShortcut},
key.Filter{Name: "E", Required: key.ModShortcut | key.ModShift},
key.Filter{Name: "A", Required: key.ModShortcut},
key.Filter{Name: "P", Optional: key.ModShift},
key.Filter{Name: "J", Optional: key.ModShift},
)
}
for {
ev, ok := gtx.Event(keys...)
if !ok {
break
}
Expand Down
10 changes: 7 additions & 3 deletions board.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ type board struct {
tool tool
// space and ctrl held turn any tool into the hand for a moment
space, ctrl bool
// writing is whether the focus is in a text field, set by the caller:
// space and the tools' letters are then its text.
writing bool
// a press: where it went down and last moved, the frame it grabbed ("" pans).
// moved tells a drag from a click.
pressed bool
Expand Down Expand Up @@ -696,8 +699,8 @@ func (b *board) hand() bool { return b.tool == toolHand || b.space || b.ctrl }
func (b *board) events(gtx layout.Context) bool {
zoomed := false
for {
// no Focus: the shortcuts work wherever the window's focus is, as long
// as no focused widget (a mockup's editor) takes the key
// no Focus: the shortcuts work wherever the window's focus is, but for
// the ones a text field writes
// Optional: a key arriving with a modifier down does not match a filter
// that leaves it out, and a real Ctrl press carries Ctrl itself; V and H
// take Shift (Caps Lock) but not Ctrl, so Ctrl+V stays a paste
Expand All @@ -717,9 +720,10 @@ func (b *board) events(gtx layout.Context) bool {
}
switch {
case e.Name == key.NameSpace:
b.space, zoomed = e.State == key.Press, true
b.space, zoomed = e.State == key.Press && !b.writing, true
case e.Name == key.NameCtrl:
b.ctrl, zoomed = e.State == key.Press, true
case b.writing:
case e.State == key.Press && e.Name == "V":
b.tool, zoomed = toolMove, true
case e.State == key.Press && e.Name == "H":
Expand Down
3 changes: 3 additions & 0 deletions docs/ceilings.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ file is the trap alone.
- **A click that did nothing is told by the state its node keeps** (`Session.answers`): a leaf that keeps only a
`widget.Clickable`, or nothing, did nothing without a goto. An adapter with a click type of its own passes for
one that answers, so its dead buttons are not told; a bare `Box` or `Spacer` never is.
- **A key goes to a filter with no Focus even as a field writes it**: a shortcut with no Ctrl, or one a field has too
(Ctrl+Z, Ctrl+A), asks `studio.writing` first. It finds a mockup's editor in the state its node keeps, or in a struct
in it; one behind a pointer or in a slice is not found, and its keys are shortcuts too.
- **The window's keys are read on every page** by the `WindowKeys` builtin `overPage` adds; a key for the
whole window goes in `windowKeys` and in the `shortcuts` table, which Ctrl+/ shows.

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ require (
modernc.org/memory v1.12.1 // indirect
)

replace gioui.org => github.com/lichdotdev/gio v0.0.0-20261127143756-265ddb097d37
replace gioui.org => github.com/lichdotdev/gio v0.0.0-20261204012332-4b0a4448fcc0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/lichdotdev/gio v0.0.0-20261127143756-265ddb097d37 h1:0pCJYQW0lFw0TcpVILUO/yA6879JM2o+JWu7XEDOZ3Q=
github.com/lichdotdev/gio v0.0.0-20261127143756-265ddb097d37/go.mod h1:x8MAOooc/v4UUaB5o6BS/FpYdxnzh3LBvZlTBmYpnlQ=
github.com/lichdotdev/gio v0.0.0-20261204012332-4b0a4448fcc0 h1:pbTvMnxFK5X3NQ1RnXIYoAJjBr9FDmLZuNxOjdj/Bs8=
github.com/lichdotdev/gio v0.0.0-20261204012332-4b0a4448fcc0/go.mod h1:x8MAOooc/v4UUaB5o6BS/FpYdxnzh3LBvZlTBmYpnlQ=
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
github.com/ncruces/go-strftime v1.1.0 h1:vtPmPWMkb539RGV9WpWT9EwJGvrOCKvMNI4obWL47Hk=
Expand Down
31 changes: 31 additions & 0 deletions gockup.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,37 @@ func State[T any](c *Ctx, init func(*T)) *T {
return e.v.(*T)
}

// writing reports whether the focus is in a text field of one of the screens.
func (s *Session) writing(gtx layout.Context) bool {
for _, states := range s.state {
for _, e := range states {
if editorFocused(gtx, reflect.ValueOf(e.v).Elem()) {
return true
}
}
}
return false
}

// editorFocused looks for the editor in v's fields too: a design system's field
// often keeps it in a struct of its own.
func editorFocused(gtx layout.Context, v reflect.Value) bool {
if v.Type() == reflect.TypeFor[widget.Editor]() {
// NewAt: Interface refuses a pointer got through an unexported field
ed := reflect.NewAt(v.Type(), v.Addr().UnsafePointer()).Interface().(*widget.Editor)
return !ed.ReadOnly && gtx.Focused(ed)
}
if v.Kind() != reflect.Struct {
return false
}
for i := range v.NumField() {
if editorFocused(gtx, v.Field(i)) {
return true
}
}
return false
}

func propsKey(n *dsl.Node) string {
var b strings.Builder
for _, p := range n.Props {
Expand Down
3 changes: 2 additions & 1 deletion present.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ func (a *studio) presentScreen() string {
// layoutPresented lays the presented screen out alone; the arrow keys go
// through the page.
func (a *studio) layoutPresented(gtx layout.Context) layout.Dimensions {
for {
// in a field they move its cursor
for !a.writing(gtx) {
ev, ok := gtx.Event(key.Filter{Name: key.NameLeftArrow}, key.Filter{Name: key.NameRightArrow})
if !ok {
break
Expand Down
10 changes: 10 additions & 0 deletions shortcuts.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ func (a *studio) shortcutsDialog(b *strings.Builder) {
b.WriteString("} } } }\n")
}

// writing reports whether the focus is in a text field, the window's, a note's
// or a mockup's: a key with no Ctrl, Ctrl+Z and Ctrl+A are then the field's, not
// shortcuts. Gio hands a key to a filter with no Focus before the field.
func (a *studio) writing(gtx layout.Context) bool {
if gtx.Focused(nil) || gtx.Focused(&a.board) {
return false
}
return a.board.edit != nil && gtx.Focused(&a.board.edit.editor) || a.uiSess.writing(gtx) || a.sess.writing(gtx)
}

// windowKeys are the keys the whole window answers, whatever page it shows:
// the dialogs' and Esc, which closes what is open, innermost first.
func (a *studio) windowKeys(gtx layout.Context) {
Expand Down
Loading
Loading