Skip to main content

IInputElement Interface

Definition

Namespace:Avalonia.Input
Assembly:Avalonia.Base
Package:Avalonia

Defines input-related functionality for a control.

public interface IInputElement

Methods

NameDescription
AddHandlerAdds a handler for the specified routed event.
FocusFocuses the control.
RaiseEventRaises a routed event.
RemoveHandlerRemoves a handler for the specified routed event.

AddHandler Method

Adds a handler for the specified routed event.

public void AddHandler(Avalonia.Interactivity.RoutedEvent routedEvent, Delegate handler, Avalonia.Interactivity.RoutingStrategies routes, bool handledEventsToo)

Parameters

routedEvent Avalonia.Interactivity.RoutedEvent

The routed event.

handler Delegate

The handler.

routes Avalonia.Interactivity.RoutingStrategies

The routing strategies to listen to.

handledEventsToo bool

Whether handled events should also be listened for.

Returns

A disposable that terminates the event subscription.

Focus Method

Focuses the control.

public bool Focus(Avalonia.Input.NavigationMethod method, Avalonia.Input.KeyModifiers keyModifiers)

Parameters

method Avalonia.Input.NavigationMethod

The method by which focus was changed.

keyModifiers Avalonia.Input.KeyModifiers

Any key modifiers active at the time of focus.

Returns

bool

RaiseEvent Method

Raises a routed event.

public void RaiseEvent(Avalonia.Interactivity.RoutedEventArgs e)

Parameters

e Avalonia.Interactivity.RoutedEventArgs

The event args.

RemoveHandler Method

Removes a handler for the specified routed event.

public void RemoveHandler(Avalonia.Interactivity.RoutedEvent routedEvent, Delegate handler)

Parameters

routedEvent Avalonia.Interactivity.RoutedEvent

The routed event.

handler Delegate

The handler.

Properties

NameDescription
CursorGets or sets the associated mouse cursor.
FocusableGets or sets a value indicating whether the control can receive keyboard focus.
IsEffectivelyEnabledGets a value indicating whether this control and all its parents are enabled.
IsEffectivelyVisibleGets a value indicating whether this control and all its parents are visible.
IsEnabledGets or sets a value indicating whether the control is enabled for user interaction.
IsFocusedGets a value indicating whether the control is focused.
IsHitTestVisibleGets a value indicating whether the control is considered for hit testing.
IsKeyboardFocusWithinGets a value indicating whether keyboard focus is anywhere within the element or its visual tree child elements.
IsPointerOverGets a value indicating whether the pointer is currently over the control.
KeyBindingsGets the key bindings for the element.

Cursor Property

Gets or sets the associated mouse cursor.

public Avalonia.Input.Cursor Cursor { get; set; }

Focusable Property

Gets or sets a value indicating whether the control can receive keyboard focus.

public bool Focusable { get; set; }

IsEffectivelyEnabled Property

Gets a value indicating whether this control and all its parents are enabled.

public bool IsEffectivelyEnabled { get; set; }

Remarks

The Avalonia.Input.IInputElement.IsEnabled property is used to toggle the enabled state for individual controls. The Avalonia.Input.IInputElement.IsEffectivelyEnabled property takes into account the Avalonia.Input.IInputElement.IsEnabled value of this control and its parent controls.

IsEffectivelyVisible Property

Gets a value indicating whether this control and all its parents are visible.

public bool IsEffectivelyVisible { get; set; }

IsEnabled Property

Gets or sets a value indicating whether the control is enabled for user interaction.

public bool IsEnabled { get; set; }

IsFocused Property

Gets a value indicating whether the control is focused.

public bool IsFocused { get; set; }

IsHitTestVisible Property

Gets a value indicating whether the control is considered for hit testing.

public bool IsHitTestVisible { get; set; }

IsKeyboardFocusWithin Property

Gets a value indicating whether keyboard focus is anywhere within the element or its visual tree child elements.

public bool IsKeyboardFocusWithin { get; set; }

IsPointerOver Property

Gets a value indicating whether the pointer is currently over the control.

public bool IsPointerOver { get; set; }

KeyBindings Property

Gets the key bindings for the element.

public System.Collections.Generic.List<Avalonia.Input.KeyBinding> KeyBindings { get; set; }

Events

NameDescription
GotFocusOccurs when the control receives focus.
KeyDownOccurs when a key is pressed while the control has focus.
KeyUpOccurs when a key is released while the control has focus.
LostFocusOccurs when the control loses focus.
PointerEnteredOccurs when the pointer enters the control.
PointerExitedOccurs when the pointer leaves the control.
PointerMovedOccurs when the pointer moves over the control.
PointerPressedOccurs when the pointer is pressed over the control.
PointerReleasedOccurs when the pointer is released over the control.
PointerWheelChangedOccurs when the mouse wheel is scrolled over the control.
TextInputOccurs when a user typed some text while the control has focus.

GotFocus Event

Occurs when the control receives focus.

public event EventHandler<Avalonia.Input.GotFocusEventArgs> GotFocus

KeyDown Event

Occurs when a key is pressed while the control has focus.

public event EventHandler<Avalonia.Input.KeyEventArgs> KeyDown

KeyUp Event

Occurs when a key is released while the control has focus.

public event EventHandler<Avalonia.Input.KeyEventArgs> KeyUp

LostFocus Event

Occurs when the control loses focus.

public event EventHandler<Avalonia.Interactivity.RoutedEventArgs> LostFocus

PointerEntered Event

Occurs when the pointer enters the control.

public event EventHandler<Avalonia.Input.PointerEventArgs> PointerEntered

PointerExited Event

Occurs when the pointer leaves the control.

public event EventHandler<Avalonia.Input.PointerEventArgs> PointerExited

PointerMoved Event

Occurs when the pointer moves over the control.

public event EventHandler<Avalonia.Input.PointerEventArgs> PointerMoved

PointerPressed Event

Occurs when the pointer is pressed over the control.

public event EventHandler<Avalonia.Input.PointerPressedEventArgs> PointerPressed

PointerReleased Event

Occurs when the pointer is released over the control.

public event EventHandler<Avalonia.Input.PointerReleasedEventArgs> PointerReleased

PointerWheelChanged Event

Occurs when the mouse wheel is scrolled over the control.

public event EventHandler<Avalonia.Input.PointerWheelEventArgs> PointerWheelChanged

TextInput Event

Occurs when a user typed some text while the control has focus.

public event EventHandler<Avalonia.Input.TextInputEventArgs> TextInput