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 ¶
- type Command
- type DropEvent
- type EditorState
- type Router
- func (q *Router) AcceptsTransfer(mime string) bool
- func (q *Router) ActionAt(p f32.Point) (system.Action, bool)
- func (q *Router) AppendSemantics(nodes []SemanticNode) []SemanticNode
- func (q *Router) ClickFocus()
- func (q *Router) ClipboardRequested() bool
- func (q *Router) ClipboardSensitive() bool
- func (q *Router) Cursor() pointer.Cursor
- func (q *Router) EditorState() EditorState
- func (q *Router) Event(filters ...event.Filter) (event.Event, bool)
- func (q *Router) Frame(frame *op.Ops)
- func (q *Router) MoveFocus(dir key.FocusDirection)
- func (q *Router) Queue(events ...event.Event)
- func (q *Router) RevealFocus(viewport image.Rectangle)
- func (q *Router) ScrollFocus(dist image.Point)
- func (q *Router) SemanticAt(pos f32.Point) (SemanticID, bool)
- func (q *Router) Source() Source
- func (q *Router) TextInputHint() (key.InputHint, bool)
- func (q *Router) TextInputState() TextInputState
- func (q *Router) WakeupTime() (time.Time, bool)
- func (q *Router) WriteClipboard() (mime string, content []byte, ok bool)
- type SemanticDesc
- type SemanticGestures
- type SemanticID
- type SemanticNode
- type Source
- func (s Source) Bounds(tag event.Tag) (image.Rectangle, bool)
- func (s Source) Disabled() Source
- func (s Source) Enabled() bool
- func (s Source) Event(filters ...event.Filter) (event.Event, bool)
- func (s Source) Execute(c Command)
- func (s Source) Focused(tag event.Tag) bool
- func (s Source) FocusedTag() event.Tag
- type SystemEvent
- type TextInputState
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 ¶
AcceptsTransfer reports whether a target in the most recent frame accepts mime.
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 ¶
ClipboardRequested reports if any new handler is waiting to read the clipboard.
func (*Router) ClipboardSensitive ¶
ClipboardSensitive reports whether the content most recently returned by WriteClipboard is marked as sensitive, see clipboard.WriteCmd.
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) Frame ¶
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) RevealFocus ¶
RevealFocus scrolls the current focus (if any) into viewport if there are scrollable parent handlers.
func (*Router) ScrollFocus ¶
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) TextInputHint ¶
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 ¶
WakeupTime returns the most recent time for doing another frame, as determined from the last call to Frame.
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 ¶
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) Enabled ¶
Enabled reports whether the source is enabled. Only enabled Sources deliver events.
func (Source) Event ¶
Event returns the next event that matches at least one of filters. If the source is disabled, no events will be reported.
func (Source) Focused ¶
Focused reports whether tag is focused, according to the most recent key.FocusEvent delivered.
func (Source) FocusedTag ¶
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 ¶
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