input

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT, Unlicense Imports: 16 Imported by: 12

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 EditorState

type EditorState struct {
	Selection struct {
		Transform f32.Affine2D
		key.Range
		key.Caret
	}
	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) 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) 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 replaces the declared handlers from the supplied operation list. The text input state, wakeup time and whether there are active profile handlers is also saved.

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 value Source is disabled.

func (Source) Enabled

func (s Source) Enabled() bool

Enabled reports whether the source is enabled. Only enabled Sources deliver events and respond to commands.

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.

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.

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.

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