event

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 9 Imported by: 0 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 event dispatches events through the capture, target, and bubble phases and synthesizes UI events from raw backend input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

Dispatcher performs 3-phase (capture → target → bubble) event dispatch.

Dispatcher is not safe for concurrent use.

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher creates a Dispatcher.

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(e event.Event, path []event.EventTarget)

Dispatch routes e through the ancestor chain described by path. path must be ordered root → target (index 0 = root, last = target). Dispatch modifies e's internal phase/target/currentTarget fields in-place.

func (*Dispatcher) DispatchWheel

func (d *Dispatcher) DispatchWheel(e *event.WheelEvent, path []event.EventTarget, scrollables []event.Scrollable)

DispatchWheel routes a WheelEvent through the ancestor chain, stopping at the first ancestor that implements Scrollable. Non-scrollable ancestors are skipped silently.

path must be ordered root → target.

type FocusReader

type FocusReader interface {
	// FocusedObject returns the currently focused render object, or nil.
	FocusedTarget() pub.EventTarget
}

FocusReader returns the currently focused render object. The Synthesizer uses it to route key events and paste events.

type HitTester

type HitTester interface {
	HitTest(x, y int) event.EventTarget
}

HitTester resolves the event target at a screen-space point. This is typically implemented by the engine.

type Synthesizer

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

Synthesizer converts raw backend input (backend.RawEvent) into structured events ready for dispatch. Click and drag synthesis applies movement tolerance. Hit testing assigns the target render object.

Synthesizer is not safe for concurrent use.

func NewSynthesizer

func NewSynthesizer(hit pub.HitTester, focus FocusReader, opts SynthesizerOptions) *Synthesizer

NewSynthesizer creates a Synthesizer with the given HitTester, FocusReader, and options.

func (*Synthesizer) Process

func (s *Synthesizer) Process(raw backend.RawEvent) []pub.Event

Process converts a raw backend event into zero or more high-level events.

func (*Synthesizer) ResolveScrollables

func (s *Synthesizer) ResolveScrollables(path []pub.EventTarget) map[pub.EventTarget]pub.Scrollable

ResolveScrollables takes a path of event targets and returns a map of those that implement Scrollable.

type SynthesizerOptions

type SynthesizerOptions struct {
	// ClickRadius is the maximum cell distance that the mouse may move
	// between mousedown and mouseup and still be synthesized as a click.
	// Default is 3.
	ClickRadius int

	// ScrollableResolver maps a target to its Scrollable, or nil.
	// Used by DispatchWheel.
	ScrollableResolver func(pub.EventTarget) pub.Scrollable
}

SynthesizerOptions configures a Synthesizer.

type Target

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

Target manages event listeners for a single object. It should be embedded in (or stored alongside) objects that need to receive events.

Target is not safe for concurrent use; it must be accessed from the single main-loop goroutine.

func (*Target) AddEventListener

func (t *Target) AddEventListener(typ event.EventType, fn event.Listener, opts ...event.Option) event.Subscription

AddEventListener registers fn as a listener for event of type typ on this target. Options control the phase (capture vs bubble), auto-cancellation (once), and the passive hint. The returned Subscription can be used to remove the listener without pointer comparison.

func (*Target) DispatchTo

func (t *Target) DispatchTo(e event.Event)

DispatchTo fires listeners on this target for the given event. It respects the phase and the once flag. Cancelled registrations are purged after each call.

func (*Target) DispatchToTarget

func (t *Target) DispatchToTarget(e event.Event)

DispatchToTarget invokes capture-registered listeners followed by bubble-registered listeners for the target phase. This mirrors the DOM specification where the target phase fires capture listeners then bubble listeners in registration order.

func (*Target) EventTarget

func (t *Target) EventTarget() event.EventTarget

EventTarget implements event.EventTarget.

func (*Target) RemoveRegistration

func (t *Target) RemoveRegistration(id uint64)

RemoveRegistration removes the registration with the given id.

Jump to

Keyboard shortcuts

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