Table of Contents

Class InputStateBase

Namespace
FlowGraph.Avalonia.Input
Assembly
FlowGraph.Avalonia.dll

Base class for input states with default implementations.

public abstract class InputStateBase : IInputState
Inheritance
InputStateBase
Implements
Derived
Inherited Members

Properties

IsModal

Gets whether this state blocks other interactions.

public virtual bool IsModal { get; }

Property Value

bool

Name

Gets the name of this state for debugging.

public abstract string Name { get; }

Property Value

string

Methods

CapturePointer(PointerEventArgs, IInputElement?)

Captures the pointer to the specified element.

protected static void CapturePointer(PointerEventArgs e, IInputElement? element)

Parameters

e PointerEventArgs
element IInputElement

Enter(InputStateContext)

Called when entering this state.

public virtual void Enter(InputStateContext context)

Parameters

context InputStateContext

Exit(InputStateContext)

Called when exiting this state.

public virtual void Exit(InputStateContext context)

Parameters

context InputStateContext

GetCanvasPosition(InputStateContext, PointerEventArgs)

Gets the current pointer position in canvas coordinates.

[Obsolete("Use GetTypedCanvasPosition() instead. The typed method works in both Visual Tree and Direct Rendering modes.")]
protected static Point GetCanvasPosition(InputStateContext context, PointerEventArgs e)

Parameters

context InputStateContext
e PointerEventArgs

Returns

Point

Remarks

DEPRECATED: Use GetTypedCanvasPosition(InputStateContext, PointerEventArgs) instead. This method only works correctly in Visual Tree mode. The typed method handles both rendering modes correctly.

GetPointerPoint(InputStateContext, PointerEventArgs)

Gets the pointer point for button state information.

protected static PointerPoint GetPointerPoint(InputStateContext context, PointerEventArgs e)

Parameters

context InputStateContext
e PointerEventArgs

Returns

PointerPoint

GetScreenPosition(InputStateContext, PointerEventArgs)

Gets the current pointer position relative to the root panel (viewport coordinates).

[Obsolete("Use GetTypedViewportPosition() instead. Returns typed ViewportPoint that prevents coordinate confusion.")]
protected static Point GetScreenPosition(InputStateContext context, PointerEventArgs e)

Parameters

context InputStateContext
e PointerEventArgs

Returns

Point

Remarks

DEPRECATED: Use GetTypedViewportPosition(InputStateContext, PointerEventArgs) instead. This method returns an untyped Avalonia.Point which doesn't indicate whether it's in canvas or viewport coordinates, making it easy to accidentally pass to the wrong conversion method.

GetTypedCanvasPosition(InputStateContext, PointerEventArgs)

Gets the current pointer position in canvas coordinates.

protected static CanvasPoint GetTypedCanvasPosition(InputStateContext context, PointerEventArgs e)

Parameters

context InputStateContext
e PointerEventArgs

Returns

CanvasPoint

Remarks

This is the preferred method for getting pointer positions when you need canvas coordinates. It uses the type-safe coordinate system and works correctly in both Visual Tree and Direct Rendering modes.

Use canvas coordinates for:

  • Hit testing on the canvas
  • Node/edge positions
  • Selection box bounds
  • Any position that needs to be stored or compared with node data

GetTypedViewportPosition(InputStateContext, PointerEventArgs)

Gets the current pointer position in viewport coordinates.

protected static ViewportPoint GetTypedViewportPosition(InputStateContext context, PointerEventArgs e)

Parameters

context InputStateContext
e PointerEventArgs

Returns

ViewportPoint

Remarks

This is the preferred method for getting pointer positions when you need viewport coordinates. It uses the type-safe coordinate system and works correctly in both Visual Tree and Direct Rendering modes.

Use viewport coordinates for:

  • Pan calculations (delta from last position)
  • Auto-pan edge detection
  • UI overlay positioning
  • Any position relative to the visible screen area

HandleKeyDown(InputStateContext, KeyEventArgs)

Handles key down events.

public virtual StateTransitionResult HandleKeyDown(InputStateContext context, KeyEventArgs e)

Parameters

context InputStateContext
e KeyEventArgs

Returns

StateTransitionResult

HandlePointerMoved(InputStateContext, PointerEventArgs)

Handles pointer moved events.

public virtual StateTransitionResult HandlePointerMoved(InputStateContext context, PointerEventArgs e)

Parameters

context InputStateContext
e PointerEventArgs

Returns

StateTransitionResult

HandlePointerPressed(InputStateContext, PointerPressedEventArgs, Control?)

Handles pointer pressed events.

public virtual StateTransitionResult HandlePointerPressed(InputStateContext context, PointerPressedEventArgs e, Control? source)

Parameters

context InputStateContext
e PointerPressedEventArgs
source Control

Returns

StateTransitionResult

HandlePointerReleased(InputStateContext, PointerReleasedEventArgs)

Handles pointer released events.

public virtual StateTransitionResult HandlePointerReleased(InputStateContext context, PointerReleasedEventArgs e)

Parameters

context InputStateContext
e PointerReleasedEventArgs

Returns

StateTransitionResult

HandlePointerWheel(InputStateContext, PointerWheelEventArgs)

Handles pointer wheel events.

public virtual StateTransitionResult HandlePointerWheel(InputStateContext context, PointerWheelEventArgs e)

Parameters

context InputStateContext
e PointerWheelEventArgs

Returns

StateTransitionResult

HitTestCanvas(InputStateContext, Point)

Performs hit testing on the main canvas. The position must be in canvas coordinates (use GetCanvasPosition, not GetScreenPosition).

protected static IInputElement? HitTestCanvas(InputStateContext context, Point canvasPosition)

Parameters

context InputStateContext
canvasPosition Point

Returns

IInputElement

HitTestForPort(InputStateContext, Point)

Performs hit testing on the main canvas specifically for finding ports. Skips edge paths and markers that might be blocking the port. The position must be in canvas coordinates.

protected static Control? HitTestForPort(InputStateContext context, Point canvasPosition)

Parameters

context InputStateContext
canvasPosition Point

Returns

Control

ReleasePointer(PointerEventArgs)

Releases pointer capture.

protected static void ReleasePointer(PointerEventArgs e)

Parameters

e PointerEventArgs

ToAvaloniaPoint(CanvasPoint)

Converts a canvas point to an Avalonia Point for backward compatibility.

protected static Point ToAvaloniaPoint(CanvasPoint canvas)

Parameters

canvas CanvasPoint

Returns

Point

ToAvaloniaPoint(ViewportPoint)

Converts a viewport point to an Avalonia Point for backward compatibility.

protected static Point ToAvaloniaPoint(ViewportPoint viewport)

Parameters

viewport ViewportPoint

Returns

Point

ToCanvasPoint(Point)

Converts an Avalonia Point to a CanvasPoint.

protected static CanvasPoint ToCanvasPoint(Point point)

Parameters

point Point

Returns

CanvasPoint

ToViewportPoint(Point)

Converts an Avalonia Point to a ViewportPoint.

protected static ViewportPoint ToViewportPoint(Point point)

Parameters

point Point

Returns

ViewportPoint

Update(InputStateContext, double)

Called each frame for states that need continuous updates (e.g., animations).

public virtual void Update(InputStateContext context, double deltaTime)

Parameters

context InputStateContext
deltaTime double