Table of Contents

Class InputContext

Namespace
Gloam.Core.Input
Assembly
Gloam.Core.dll

Default implementation of input context

public class InputContext : IInputContext
Inheritance
InputContext
Implements
Inherited Members

Constructors

InputContext(string, int)

Initializes a new input context

public InputContext(string name, int priority = 0)

Parameters

name string
priority int

Properties

IsActive

Whether this context is currently active

public bool IsActive { get; set; }

Property Value

bool

Name

Name of the input context

public string Name { get; }

Property Value

string

Priority

Priority of this context (higher priority contexts are processed first)

public int Priority { get; }

Property Value

int

Methods

AddBinding(InputBinding, Action)

Adds an input binding to this context with synchronous handler

public void AddBinding(InputBinding binding, Action handler)

Parameters

binding InputBinding
handler Action

AddBinding(InputBinding, Func<Task>)

Adds an input binding to this context

public void AddBinding(InputBinding binding, Func<Task> handler)

Parameters

binding InputBinding
handler Func<Task>

ClearBindings()

Clears all bindings from this context

public void ClearBindings()

Contextual(string, int)

Creates a contextual input context with normal priority

public static InputContext Contextual(string name, int priority = 0)

Parameters

name string
priority int

Returns

InputContext

Global(string)

Creates a global input context with high priority

public static InputContext Global(string name)

Parameters

name string

Returns

InputContext

ProcessInputAsync(IInputDevice, CancellationToken)

Processes input for this context

public Task<bool> ProcessInputAsync(IInputDevice inputDevice, CancellationToken ct = default)

Parameters

inputDevice IInputDevice
ct CancellationToken

Returns

Task<bool>

True if input was handled and should not propagate to lower priority contexts

RemoveBinding(InputAction)

Removes an input binding from this context

public bool RemoveBinding(InputAction action)

Parameters

action InputAction

Returns

bool