Class InputContext
Represents a context for input bindings with priority-based resolution. Input contexts allow for scene-specific or layered input handling.
Inherited Members
Namespace: PopcorningGuineaPig.Engine.Input
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public class InputContext
Constructors
| Edit this page View SourceInputContext(string, int, bool)
Creates a new input context.
Declaration
public InputContext(string name, int priority = 0, bool allowPassthrough = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the context |
| int | priority | Priority of the context (higher = more important) |
| bool | allowPassthrough | Whether to allow input passthrough |
Properties
| Edit this page View SourceAllowPassthrough
Whether input should pass through to lower priority contexts if not handled.
Declaration
public bool AllowPassthrough { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
BindingCount
Gets the number of bindings in this context.
Declaration
public int BindingCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Bindings
Collection of all bindings in this context.
Declaration
public IReadOnlyDictionary<InputKey, InputBinding> Bindings { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<InputKey, InputBinding> |
Name
Name of this input context.
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Priority
Priority of this context. Higher values have higher priority.
Declaration
public int Priority { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceAddBinding(InputBinding)
Adds a binding to this context.
Declaration
public void AddBinding(InputBinding binding)
Parameters
| Type | Name | Description |
|---|---|---|
| InputBinding | binding | The binding to add |
ClearBindings()
Clears all bindings from this context.
Declaration
public void ClearBindings()
GetBinding(InputKey)
Gets a binding by input key.
Declaration
public InputBinding GetBinding(InputKey inputKey)
Parameters
| Type | Name | Description |
|---|---|---|
| InputKey | inputKey | The input key to look up |
Returns
| Type | Description |
|---|---|
| InputBinding | The binding if found, null otherwise |
GetBindingById(string)
Gets a binding by ID.
Declaration
public InputBinding GetBindingById(string bindingId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | bindingId | The binding ID to look up |
Returns
| Type | Description |
|---|---|
| InputBinding | The binding if found, null otherwise |
GetMatchingBindings(InputKey)
Gets all bindings that match the specified input key.
Declaration
public IEnumerable<InputBinding> GetMatchingBindings(InputKey inputKey)
Parameters
| Type | Name | Description |
|---|---|---|
| InputKey | inputKey | The input key to match |
Returns
| Type | Description |
|---|---|
| IEnumerable<InputBinding> | Collection of matching bindings |
HandlesInput(InputKey)
Checks if this context handles the specified input key.
Declaration
public bool HandlesInput(InputKey inputKey)
Parameters
| Type | Name | Description |
|---|---|---|
| InputKey | inputKey | The input key to check |
Returns
| Type | Description |
|---|---|
| bool | True if the context has an enabled binding for the input key |
RemoveBinding(string)
Removes a binding by ID.
Declaration
public bool RemoveBinding(string bindingId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | bindingId | ID of the binding to remove |
Returns
| Type | Description |
|---|---|
| bool | True if the binding was removed, false if not found |
ToString()
Returns a string representation of the context.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |