Documentation
¶
Index ¶
- Constants
- Variables
- func ReadModifiers() types.KeyModifiers
- type CallbackHandle
- type HandlerRegistry
- type HitCircle
- type HitPolygon
- type HitRect
- type Manager
- func (m *Manager) CapturePointer(pointerID int, n *node.Node)
- func (m *Manager) CollectInteractable(n *node.Node, buf []*node.Node) []*node.Node
- func (m *Manager) FireClick(n *node.Node, pointerID int, wx, wy float64, button types.MouseButton, ...)
- func (m *Manager) FireDrag(n *node.Node, pointerID int, ...)
- func (m *Manager) FireDragEnd(n *node.Node, pointerID int, ...)
- func (m *Manager) FireDragStart(n *node.Node, pointerID int, ...)
- func (m *Manager) FirePinch(ctx node.PinchContext, mods types.KeyModifiers)
- func (m *Manager) FirePointerDown(n *node.Node, pointerID int, wx, wy float64, button types.MouseButton, ...)
- func (m *Manager) HitTest(root *node.Node, worldX, worldY float64) *node.Node
- func (m *Manager) InjectClick(x, y float64)
- func (m *Manager) InjectDrag(fromX, fromY, toX, toY float64, frames int)
- func (m *Manager) InjectHover(x, y float64)
- func (m *Manager) InjectMove(x, y float64)
- func (m *Manager) InjectPress(x, y float64)
- func (m *Manager) InjectRelease(x, y float64)
- func (m *Manager) IsPointerDown(button types.MouseButton) bool
- func (m *Manager) OnBackgroundClick(fn func(node.ClickContext)) CallbackHandle
- func (m *Manager) OnClick(fn func(node.ClickContext)) CallbackHandle
- func (m *Manager) OnDrag(fn func(node.DragContext)) CallbackHandle
- func (m *Manager) OnDragEnd(fn func(node.DragContext)) CallbackHandle
- func (m *Manager) OnDragStart(fn func(node.DragContext)) CallbackHandle
- func (m *Manager) OnPinch(fn func(node.PinchContext)) CallbackHandle
- func (m *Manager) OnPointerDown(fn func(node.PointerContext)) CallbackHandle
- func (m *Manager) OnPointerEnter(fn func(node.PointerContext)) CallbackHandle
- func (m *Manager) OnPointerLeave(fn func(node.PointerContext)) CallbackHandle
- func (m *Manager) OnPointerMove(fn func(node.PointerContext)) CallbackHandle
- func (m *Manager) OnPointerUp(fn func(node.PointerContext)) CallbackHandle
- func (m *Manager) PointerPosition() (x, y float64)
- func (m *Manager) ProcessInjectedInput(root *node.Node, mods types.KeyModifiers) bool
- func (m *Manager) ProcessInput(root *node.Node)
- func (m *Manager) ProcessPointer(root *node.Node, pointerID int, wx, wy, sx, sy float64, pressed bool, ...)
- func (m *Manager) ReleasePointer(pointerID int)
- func (m *Manager) SetDragDeadZone(pixels float64)
- type SyntheticPointerEvent
Constants ¶
const ( MaxPointers = 10 // pointer 0 = mouse, 1-9 = touch DefaultDragDeadZone = 4.0 // pixels )
Variables ¶
var ( // ScreenToWorldFn converts screen coordinates to world coordinates. // Set by root to use the primary camera's ScreenToWorld. ScreenToWorldFn func(sx, sy float64) (float64, float64) // NodeDimensionsFn returns the display dimensions for a node. // Set by root (delegates to camera.NodeDimensions or render.NodeDimensions). NodeDimensionsFn func(n *node.Node) (w, h float64) // EmitInteractionEventFn bridges input events to the ECS entity store. // Set by root; nil when no EntityStore is configured. EmitInteractionEventFn func(eventType types.EventType, n *node.Node, wx, wy, lx, ly float64, button types.MouseButton, mods types.KeyModifiers, drag node.DragContext, pinch node.PinchContext) // RebuildSortedChildrenFn sorts a node's children by ZIndex. // Set by root (delegates to render.RebuildSortedChildren). RebuildSortedChildrenFn func(n *node.Node) )
Functions ¶
func ReadModifiers ¶
func ReadModifiers() types.KeyModifiers
ReadModifiers reads the current keyboard modifier state.
Types ¶
type CallbackHandle ¶
type CallbackHandle struct {
// contains filtered or unexported fields
}
CallbackHandle allows removing a registered scene-level callback.
type HandlerRegistry ¶
type HandlerRegistry struct {
// contains filtered or unexported fields
}
HandlerRegistry stores event handler slices for all event types.
type HitCircle ¶
type HitCircle struct {
CenterX, CenterY, Radius float64
}
HitCircle is a circular hit area in local coordinates.
type HitPolygon ¶
HitPolygon is a convex polygon hit area in local coordinates.
func (HitPolygon) Contains ¶
func (p HitPolygon) Contains(x, y float64) bool
Contains reports whether (x, y) lies inside a convex polygon.
type HitRect ¶
type HitRect struct {
X, Y, Width, Height float64
}
HitRect is an axis-aligned rectangular hit area in local coordinates.
type Manager ¶
type Manager struct {
Handlers HandlerRegistry
Captured [MaxPointers]*node.Node
Pointers [MaxPointers]pointerState
HitBuf []*node.Node
DragDeadZone float64
TouchMap [MaxPointers]ebiten.TouchID
TouchUsed [MaxPointers]bool
PrevTouchIDs []ebiten.TouchID
Pinch pinchState
InjectQueue []SyntheticPointerEvent
}
Manager owns all input state. Replaces the input-related fields on Scene.
func (*Manager) CapturePointer ¶
CapturePointer routes all events for pointerID to the given node.
func (*Manager) CollectInteractable ¶
CollectInteractable is the exported version of collectInteractable (for testing).
func (*Manager) FireClick ¶
func (m *Manager) FireClick(n *node.Node, pointerID int, wx, wy float64, button types.MouseButton, mods types.KeyModifiers)
FireClick is the exported version of fireClick.
func (*Manager) FireDrag ¶
func (m *Manager) FireDrag(n *node.Node, pointerID int, wx, wy, startX, startY, deltaX, deltaY, screenDX, screenDY float64, button types.MouseButton, mods types.KeyModifiers)
FireDrag is the exported version of fireDrag.
func (*Manager) FireDragEnd ¶
func (m *Manager) FireDragEnd(n *node.Node, pointerID int, wx, wy, startX, startY, deltaX, deltaY, screenDX, screenDY float64, button types.MouseButton, mods types.KeyModifiers)
FireDragEnd is the exported version of fireDragEnd.
func (*Manager) FireDragStart ¶
func (m *Manager) FireDragStart(n *node.Node, pointerID int, wx, wy, startX, startY, deltaX, deltaY, screenDX, screenDY float64, button types.MouseButton, mods types.KeyModifiers)
FireDragStart is the exported version of fireDragStart.
func (*Manager) FirePinch ¶
func (m *Manager) FirePinch(ctx node.PinchContext, mods types.KeyModifiers)
FirePinch is the exported version of firePinch.
func (*Manager) FirePointerDown ¶
func (m *Manager) FirePointerDown(n *node.Node, pointerID int, wx, wy float64, button types.MouseButton, mods types.KeyModifiers)
FirePointerDown is the exported version of firePointerDown (for testing and bridging).
func (*Manager) HitTest ¶
HitTest finds the topmost interactable node at (worldX, worldY). Returns nil if nothing is hit.
func (*Manager) InjectClick ¶
InjectClick is a convenience that queues a press followed by a release at the same screen coordinates. Consumes two frames.
func (*Manager) InjectDrag ¶
InjectDrag queues a full drag sequence: press at (fromX, fromY), linearly interpolated moves over frames-2 intermediate frames, and release at (toX, toY). Minimum frames is 2.
func (*Manager) InjectHover ¶
InjectHover queues a free pointer move (no button held) at the given screen coordinates. Use this to trigger OnPointerEnter / OnPointerLeave callbacks without pressing a button.
func (*Manager) InjectMove ¶
InjectMove queues a pointer move event at the given screen coordinates with the button held down.
func (*Manager) InjectPress ¶
InjectPress queues a pointer press event at the given screen coordinates.
func (*Manager) InjectRelease ¶
InjectRelease queues a pointer release event at the given screen coordinates.
func (*Manager) IsPointerDown ¶
func (m *Manager) IsPointerDown(button types.MouseButton) bool
IsPointerDown reports whether the given mouse button is currently pressed. This checks the mouse pointer (pointer 0) state.
func (*Manager) OnBackgroundClick ¶
func (m *Manager) OnBackgroundClick(fn func(node.ClickContext)) CallbackHandle
func (*Manager) OnClick ¶
func (m *Manager) OnClick(fn func(node.ClickContext)) CallbackHandle
func (*Manager) OnDrag ¶
func (m *Manager) OnDrag(fn func(node.DragContext)) CallbackHandle
func (*Manager) OnDragEnd ¶
func (m *Manager) OnDragEnd(fn func(node.DragContext)) CallbackHandle
func (*Manager) OnDragStart ¶
func (m *Manager) OnDragStart(fn func(node.DragContext)) CallbackHandle
func (*Manager) OnPinch ¶
func (m *Manager) OnPinch(fn func(node.PinchContext)) CallbackHandle
func (*Manager) OnPointerDown ¶
func (m *Manager) OnPointerDown(fn func(node.PointerContext)) CallbackHandle
func (*Manager) OnPointerEnter ¶
func (m *Manager) OnPointerEnter(fn func(node.PointerContext)) CallbackHandle
func (*Manager) OnPointerLeave ¶
func (m *Manager) OnPointerLeave(fn func(node.PointerContext)) CallbackHandle
func (*Manager) OnPointerMove ¶
func (m *Manager) OnPointerMove(fn func(node.PointerContext)) CallbackHandle
func (*Manager) OnPointerUp ¶
func (m *Manager) OnPointerUp(fn func(node.PointerContext)) CallbackHandle
func (*Manager) PointerPosition ¶
PointerPosition returns the last known pointer position in screen space for the mouse pointer (pointer 0).
func (*Manager) ProcessInjectedInput ¶
ProcessInjectedInput pops one event from the inject queue, converts screen→world via ScreenToWorldFn, and feeds it through processPointer. Returns true if an event was consumed (real mouse input should be skipped).
func (*Manager) ProcessInput ¶
ProcessInput handles all mouse and touch input for a frame. root is the scene graph root for hit testing.
func (*Manager) ProcessPointer ¶
func (m *Manager) ProcessPointer(root *node.Node, pointerID int, wx, wy, sx, sy float64, pressed bool, button types.MouseButton, mods types.KeyModifiers)
ProcessPointer is the exported version of processPointer (for testing and bridging).
func (*Manager) ReleasePointer ¶
ReleasePointer stops routing events for pointerID to a captured node.
func (*Manager) SetDragDeadZone ¶
SetDragDeadZone sets the minimum movement in pixels before a drag starts.
type SyntheticPointerEvent ¶
type SyntheticPointerEvent struct {
ScreenX float64
ScreenY float64
Pressed bool
Button types.MouseButton
}
SyntheticPointerEvent represents a single injected pointer event. Screen coordinates are used (matching what an AI sees in screenshots) and converted to world coordinates via ScreenToWorldFn.