Help us shape the future of Go! Take the 2026 Go Developer Survey

tab

package
v0.87.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package tab runs a widget tree in a plain browser tab, on a <canvas>, through go-widgets/webcanvas: no compositor, no SharedArrayBuffer, no cross-origin isolation. It is what window.Open returns on js/wasm when the page is not a wasmdesk/wasmbox client, so ONE application runs unchanged natively, inside wasmdesk, and in an ordinary tab served from anywhere.

Tree, the adapter between a widget tree and webcanvas's App, has no build tag: it is plain Go, tested off the browser. Only tab_js.go touches the DOM.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend draws into the <canvas> whose id it was opened with.

func Open

func Open(canvas string, w, h int, theme *toolkit.Theme) (*Backend, error)

Open checks that the page has the canvas, and returns a Backend for it.

func (*Backend) Close

func (b *Backend) Close() error

Close does nothing: a tab ends when the page does.

func (*Backend) Run

func (b *Backend) Run(root toolkit.Widget) error

Run drives root until the page goes away.

func (*Backend) Size

func (b *Backend) Size() (int, int)

Size is the surface in pixels.

func (*Backend) String

func (b *Backend) String() string

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree is a widget tree as a webcanvas scene.

func NewTree

func NewTree(root toolkit.Widget, w, h int, theme *toolkit.Theme) *Tree

NewTree adapts root, laid out on a w×h surface painted with theme.

func (*Tree) Char

func (t *Tree) Char(s string) bool

Char is a printable character typed with no Ctrl, Meta or Alt.

func (*Tree) Click

func (t *Tree) Click(x, y int) bool

Click is a left-button press.

func (*Tree) Context

func (t *Tree) Context(x, y int) bool

Context is a right-button press.

func (*Tree) Draw

func (t *Tree) Draw(buf []byte)

Draw paints the tree into buf, the w×h RGBA framebuffer webcanvas keeps between frames -- which is what lets an incremental root repaint only what it reports damaged.

func (*Tree) KeyDown

func (t *Tree) KeyDown(s string) bool

KeyDown is a named key, or a modified one -- whose modifiers Modifiers has just recorded, so Ctrl+A arrives as "a" with Ctrl set.

func (*Tree) Modifiers

func (t *Tree) Modifiers(m webcanvas.Modifiers)

Modifiers records the modifier keys of the event about to be delivered.

func (*Tree) Move

func (t *Tree) Move(x, y int) bool

Move is a pointer move: a drag while the button is held.

func (*Tree) Release

func (t *Tree) Release(x, y int) bool

Release ends a press.

func (*Tree) Resize

func (t *Tree) Resize(w, h int) (int, int)

Resize follows the canvas to the size the page lays it out at.

func (*Tree) Scroll

func (t *Tree) Scroll(x, y, dx, dy int) bool

Scroll is the wheel, in toolkit rows, at the pointer.

func (*Tree) Size

func (t *Tree) Size() (int, int)

Size is the surface in pixels.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL