Class AvaloniaInput
Public read-only facade over the Avalonia input state. Use this from game code to discover which viewport currently has pointer focus, allowing a single Game to route per-update input to the correct sub-region when multiple SubViewGameControl viewports share the same game instance.
public static class AvaloniaInput
- Inheritance
-
AvaloniaInput
- Inherited Members
Properties
FocusedViewportTag
The Tag value of the viewport control that most recently received pointer
focus, or null if no game viewport is focused. Set by
SubViewGameControl on got-focus and cleared on lost-focus; the main
MonoGameControl sets it to its own Tag value on pointer press.
public static object? FocusedViewportTag { get; }
Property Value
Remarks
Assign a unique Tag to each viewport in XAML, then check this property in
your game's Update() to route input to the correct sub-view:
// doctest-ignore
// XAML: <controls:SubViewGameControl Tag="player1" ... />
// <controls:SubViewGameControl Tag="player2" ... />
if (AvaloniaInput.FocusedViewportTag is string viewport)
{
if (viewport == "player1") UpdatePlayer1(gameTime);
if (viewport == "player2") UpdatePlayer2(gameTime);
}