Input, focus and async
Focus and tab order, overlays, animation, background work, shortcuts, file drops and the clipboard.
- Focus. Interactive DSL widgets register themselves. Tab order is Layout order.
.DefaultFocus()/c.Focus().EnsureFocus(w)picks a fallback when nothing is focused. Open dialogs callBeginModalthenSetModalso Tab and keys stay inside the dialog. - Overlays. Menus, selects, dialogs, and toasts call
c.Overlay(el). Overlays paint and hit-test on top of the body. - Animation.
c.Animate(d)schedules a repaint withind(caret blink, spinner, polling). The runtime waits the minimum requested duration, or sleeps until the next OS event. - Background work. Safe to call
c.Invalidate()from any goroutine (a job finished, HTTP returned). Typical pattern: a result channel drained at the top ofBody, plusc.Animate(30*time.Millisecond)while a request is in flight. - Shortcuts. Read
c.Keyboard()inBody, or implementyoga.KeyHookwhen a focused widget would otherwise eat the key. - File drops.
c.Mouse().Droppedholds the paths of files dropped on the window this frame, at the pointer position. Set it to nil once taken. - Clipboard images.
c.Clipboard()may also be aninput.ImageClipboard;GetImage()returns the clipboard's picture as PNG. It works on macOS, and on Linux whenwl-pasteorxclipis installed.MemClipboard.SetImagefills it in tests.
Pointer handlers set m.Consumed = true to stop bubbling. Overlay hit-testing runs first.