input

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT, MIT, Unlicense Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package input implements input routing and tracking of interface state for a window.

The Source is the interface between the window and the widgets of a user interface and is exposed by gioui.org/app.FrameEvent received from windows.

The Router is used by gioui.org/app.Window to track window state and route events from the platform to event handlers. It is otherwise only useful for using Gio with external window implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	ImplementsCommand()
}

Command represents a request such as moving the focus, or initiating a clipboard read. Commands are queued by calling [Source.Queue].

type DropEvent

type DropEvent struct {
	// Position is the drop location in window coordinates, in pixels.
	Position f32.Point
	// Type is the MIME type of the offered data.
	Type string
	// Open returns a new reader on each call so Router can replay the event.
	// The data must remain available until the event is processed.
	// Router closes unused readers. The target closes readers it opens.
	Open func() io.ReadCloser
}

DropEvent reports data dropped onto a window from another application. Router sends transfer.InitiateEvent and transfer.CancelEvent to matching targets. The target at Position also receives a transfer.DataEvent.

func (DropEvent) ImplementsEvent

func (DropEvent) ImplementsEvent()

type EditorState

type EditorState struct {
	Selection struct {
		Transform f32.Affine2D
		key.Range
		key.Caret
		CompositionBounds image.Rectangle
	}
	Snippet key.Snippet
}

EditorState represents the state of an editor needed by input handlers.

type Router

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

Router tracks the io/event.Tag identifiers of user interface widgets and routes events to them. Source is its interface exposed to widgets.

func (*Router) AcceptsTransfer

func (q *Router) AcceptsTransfer(mime string) bool

AcceptsTransfer reports whether a target in the most recent frame accepts mime.

func (*Router) ActionAt

func (q *Router) ActionAt(p f32.Point) (system.Action, bool)

func (*Router) AppendSemantics

func (q *Router) AppendSemantics(nodes []SemanticNode) []SemanticNode

AppendSemantics appends the semantic tree to nodes, and returns the result. The root node is the first added.

func (*Router) ClickFocus

func (q *Router) ClickFocus()

func (*Router) ClipboardRequested

func (q *Router) ClipboardRequested() bool

ClipboardRequested reports if any new handler is waiting to read the clipboard.

func (*Router) ClipboardSensitive

func (q *Router) ClipboardSensitive() bool

ClipboardSensitive reports whether the content most recently returned by WriteClipboard is marked as sensitive, see clipboard.WriteCmd.

func (*Router) Cursor

func (q *Router) Cursor() pointer.Cursor

Cursor returns the last cursor set.

func (*Router) EditorState

func (q *Router) EditorState() EditorState

EditorState returns the editor state for the focused handler, or the zero value if there is none.

func (*Router) Event

func (q *Router) Event(filters ...event.Filter) (event.Event, bool)

func (*Router) Frame

func (q *Router) Frame(frame *op.Ops)

Frame completes the current frame and starts a new with the handlers from the frame argument. Remaining events are discarded, unless they were deferred by a command.

func (*Router) MoveFocus

func (q *Router) MoveFocus(dir key.FocusDirection)

func (*Router) Queue

func (q *Router) Queue(events ...event.Event)

Queue events to be routed.

func (*Router) RevealFocus

func (q *Router) RevealFocus(viewport image.Rectangle)

RevealFocus scrolls the current focus (if any) into viewport if there are scrollable parent handlers.

func (*Router) ScrollFocus

func (q *Router) ScrollFocus(dist image.Point)

ScrollFocus scrolls the focused widget, if any, by dist.

func (*Router) SemanticAt

func (q *Router) SemanticAt(pos f32.Point) (SemanticID, bool)

SemanticAt returns the first semantic description under pos, if any.

func (*Router) Source

func (q *Router) Source() Source

Source returns a Source backed by this Router.

func (*Router) TextInputHint

func (q *Router) TextInputHint() (key.InputHint, bool)

TextInputHint returns the input mode from the most recent key.InputOp.

func (*Router) TextInputState

func (q *Router) TextInputState() TextInputState

TextInputState returns the input state from the most recent call to Frame.

func (*Router) WakeupTime

func (q *Router) WakeupTime() (time.Time, bool)

WakeupTime returns the most recent time for doing another frame, as determined from the last call to Frame.

func (*Router) WriteClipboard

func (q *Router) WriteClipboard() (mime string, content []byte, ok bool)

WriteClipboard returns the most recent content to be copied to the clipboard, if any.

type SemanticDesc

type SemanticDesc struct {
	Class       semantic.ClassOp
	Description string
	Label       string
	Selected    bool
	Disabled    bool
	Gestures    SemanticGestures
	Bounds      image.Rectangle
}

SemanticDesc provides a semantic description of a UI component.

type SemanticGestures

type SemanticGestures int

SemanticGestures is a bit-set of supported gestures.

const (
	ClickGesture SemanticGestures = 1 << iota
	ScrollGesture
)

func (SemanticGestures) String

func (s SemanticGestures) String() string

type SemanticID

type SemanticID uint

SemanticID uniquely identifies a SemanticDescription.

By convention, the zero value denotes the non-existent ID.

type SemanticNode

type SemanticNode struct {
	ID       SemanticID
	ParentID SemanticID
	Children []SemanticNode
	Desc     SemanticDesc
	// contains filtered or unexported fields
}

SemanticNode represents a node in the tree describing the components contained in a frame.

type Source

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

Source implements the interface between a Router and user interface widgets. The zero-value Source is disabled.

func (Source) Bounds

func (s Source) Bounds(tag event.Tag) (image.Rectangle, bool)

Bounds returns the window-space bounds of the clip area where tag's event.Op was added in the most recent frame, and whether it was added.

giokit patch: layout never learns absolute positions in Gio (transforms apply when ops are processed), but popups need them to flip and shift at window edges. The router has them from the last frame: anchors are a frame behind while they move, which is fine for placement decisions. It works on disabled Sources too: it reads geometry, not events.

func (Source) Disabled

func (s Source) Disabled() Source

Disabled returns a copy of this source that don't deliver any events.

func (Source) Enabled

func (s Source) Enabled() bool

Enabled reports whether the source is enabled. Only enabled Sources deliver events.

func (Source) Event

func (s Source) Event(filters ...event.Filter) (event.Event, bool)

Event returns the next event that matches at least one of filters. If the source is disabled, no events will be reported.

func (Source) Execute

func (s Source) Execute(c Command)

Execute a command.

func (Source) Focused

func (s Source) Focused(tag event.Tag) bool

Focused reports whether tag is focused, according to the most recent key.FocusEvent delivered.

func (Source) FocusedTag

func (s Source) FocusedTag() event.Tag

FocusedTag returns the tag that has keyboard focus, or nil.

giokit patch: lets a harness name the focused widget (via Bounds and the semantic tree), so tests can assert focus traps and Tab order.

type SystemEvent

type SystemEvent struct {
	Event event.Event
}

SystemEvent is a marker for events that have platform specific side-effects. SystemEvents are never matched by catch-all filters; only filters that explicitly match the event, such as a gioui.org/io/key.Filter with a non-empty Name, receive them. gioui.org/app.Window uses SystemEvent for keys reserved for focus navigation: Tab and Shift-Tab, and on mobile the arrow keys. If no handler matches such an event, the window moves focus instead.

func (SystemEvent) ImplementsEvent

func (SystemEvent) ImplementsEvent()

type TextInputState

type TextInputState uint8
const (
	TextInputKeep TextInputState = iota
	TextInputClose
	TextInputOpen
)

func (TextInputState) String

func (t TextInputState) String() string

Jump to

Keyboard shortcuts

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