Table of Contents

Class InputElement

Namespace
Avalonia.Input
Assembly
Avalonia.Base.dll

Implements input-related functionality for a control.

[PseudoClasses(new string[] { ":disabled", ":focus", ":focus-visible", ":focus-within", ":pointerover" })]
public class InputElement : Interactive, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement
Inheritance
InputElement
Implements
Derived
Inherited Members
Extension Methods

Constructors

InputElement()

public InputElement()

Fields

CursorProperty

Gets or sets associated mouse cursor.

public static readonly StyledProperty<Cursor?> CursorProperty

Field Value

StyledProperty<Cursor>

DoubleTappedEvent

Defines the DoubleTapped event.

public static readonly RoutedEvent<TappedEventArgs> DoubleTappedEvent

Field Value

RoutedEvent<TappedEventArgs>

FocusableProperty

Defines the Focusable property.

public static readonly StyledProperty<bool> FocusableProperty

Field Value

StyledProperty<bool>

GotFocusEvent

Defines the GotFocus event.

public static readonly RoutedEvent<GotFocusEventArgs> GotFocusEvent

Field Value

RoutedEvent<GotFocusEventArgs>

HoldingEvent

Defines the Holding event.

public static readonly RoutedEvent<HoldingRoutedEventArgs> HoldingEvent

Field Value

RoutedEvent<HoldingRoutedEventArgs>

IsEffectivelyEnabledProperty

Defines the IsEffectivelyEnabled property.

public static readonly DirectProperty<InputElement, bool> IsEffectivelyEnabledProperty

Field Value

DirectProperty<InputElement, bool>

IsEnabledProperty

Defines the IsEnabled property.

public static readonly StyledProperty<bool> IsEnabledProperty

Field Value

StyledProperty<bool>

IsFocusedProperty

Defines the IsFocused property.

public static readonly DirectProperty<InputElement, bool> IsFocusedProperty

Field Value

DirectProperty<InputElement, bool>

IsHitTestVisibleProperty

Defines the IsHitTestVisible property.

public static readonly StyledProperty<bool> IsHitTestVisibleProperty

Field Value

StyledProperty<bool>

IsKeyboardFocusWithinProperty

Defines the IsKeyboardFocusWithin property.

public static readonly DirectProperty<InputElement, bool> IsKeyboardFocusWithinProperty

Field Value

DirectProperty<InputElement, bool>

IsPointerOverProperty

Defines the IsPointerOver property.

public static readonly DirectProperty<InputElement, bool> IsPointerOverProperty

Field Value

DirectProperty<InputElement, bool>

IsTabStopProperty

Defines the IsTabStop property.

public static readonly StyledProperty<bool> IsTabStopProperty

Field Value

StyledProperty<bool>

KeyDownEvent

Defines the KeyDown event.

public static readonly RoutedEvent<KeyEventArgs> KeyDownEvent

Field Value

RoutedEvent<KeyEventArgs>

KeyUpEvent

Defines the KeyUp event.

public static readonly RoutedEvent<KeyEventArgs> KeyUpEvent

Field Value

RoutedEvent<KeyEventArgs>

LostFocusEvent

Defines the LostFocus event.

public static readonly RoutedEvent<RoutedEventArgs> LostFocusEvent

Field Value

RoutedEvent<RoutedEventArgs>

PointerCaptureLostEvent

Defines the PointerCaptureLost routed event.

public static readonly RoutedEvent<PointerCaptureLostEventArgs> PointerCaptureLostEvent

Field Value

RoutedEvent<PointerCaptureLostEventArgs>

PointerEnteredEvent

Defines the PointerEntered event.

public static readonly RoutedEvent<PointerEventArgs> PointerEnteredEvent

Field Value

RoutedEvent<PointerEventArgs>

PointerExitedEvent

Defines the PointerExited event.

public static readonly RoutedEvent<PointerEventArgs> PointerExitedEvent

Field Value

RoutedEvent<PointerEventArgs>

PointerMovedEvent

Defines the PointerMoved event.

public static readonly RoutedEvent<PointerEventArgs> PointerMovedEvent

Field Value

RoutedEvent<PointerEventArgs>

PointerPressedEvent

Defines the PointerPressed event.

public static readonly RoutedEvent<PointerPressedEventArgs> PointerPressedEvent

Field Value

RoutedEvent<PointerPressedEventArgs>

PointerReleasedEvent

Defines the PointerReleased event.

public static readonly RoutedEvent<PointerReleasedEventArgs> PointerReleasedEvent

Field Value

RoutedEvent<PointerReleasedEventArgs>

PointerWheelChangedEvent

Defines the PointerWheelChanged event.

public static readonly RoutedEvent<PointerWheelEventArgs> PointerWheelChangedEvent

Field Value

RoutedEvent<PointerWheelEventArgs>

TabIndexProperty

Defines the TabIndex property.

public static readonly StyledProperty<int> TabIndexProperty

Field Value

StyledProperty<int>

TappedEvent

Defines the Tapped event.

public static readonly RoutedEvent<TappedEventArgs> TappedEvent

Field Value

RoutedEvent<TappedEventArgs>

TextInputEvent

Defines the TextInput event.

public static readonly RoutedEvent<TextInputEventArgs> TextInputEvent

Field Value

RoutedEvent<TextInputEventArgs>

TextInputMethodClientRequestedEvent

Defines the TextInputMethodClientRequested event.

public static readonly RoutedEvent<TextInputMethodClientRequestedEventArgs> TextInputMethodClientRequestedEvent

Field Value

RoutedEvent<TextInputMethodClientRequestedEventArgs>

Properties

Cursor

Gets or sets associated mouse cursor.

public Cursor? Cursor { get; set; }

Property Value

Cursor

Focusable

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

public bool Focusable { get; set; }

Property Value

bool

GestureRecognizers

public GestureRecognizerCollection GestureRecognizers { get; }

Property Value

GestureRecognizerCollection

IsEffectivelyEnabled

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

public bool IsEffectivelyEnabled { get; }

Property Value

bool

Remarks

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

IsEnabled

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

public bool IsEnabled { get; set; }

Property Value

bool

IsEnabledCore

Allows a derived class to override the enabled state of the control.

protected virtual bool IsEnabledCore { get; }

Property Value

bool

Remarks

Derived controls may wish to disable the enabled state of the control without overwriting the user-supplied IsEnabled setting. This can be done by overriding this property to return the overridden enabled state. If the value returned from IsEnabledCore should change, then the derived control should call UpdateIsEffectivelyEnabled().

IsFocused

Gets a value indicating whether the control is focused.

public bool IsFocused { get; }

Property Value

bool

IsHitTestVisible

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

public bool IsHitTestVisible { get; set; }

Property Value

bool

IsKeyboardFocusWithin

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

public bool IsKeyboardFocusWithin { get; }

Property Value

bool

IsPointerOver

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

public bool IsPointerOver { get; }

Property Value

bool

IsTabStop

Gets or sets a value that indicates whether the control is included in tab navigation.

public bool IsTabStop { get; set; }

Property Value

bool

KeyBindings

Gets the key bindings for the element.

public List<KeyBinding> KeyBindings { get; }

Property Value

List<KeyBinding>

TabIndex

Gets or sets a value that determines the order in which elements receive focus when the user navigates through controls by pressing the Tab key.

public int TabIndex { get; set; }

Property Value

int

Methods

Focus(NavigationMethod, KeyModifiers)

Focuses the control.

public bool Focus(NavigationMethod method = NavigationMethod.Unspecified, KeyModifiers keyModifiers = KeyModifiers.None)

Parameters

method NavigationMethod

The method by which focus was changed.

keyModifiers KeyModifiers

Any key modifiers active at the time of focus.

Returns

bool

OnAccessKey(RoutedEventArgs)

This method is used to execute the action on an effective IInputElement when a corresponding access key has been invoked. By default, the Focus() method is invoked with the NavigationMethod.Tab to indicate a visual focus adorner. Overwrite this method if other methods or additional functionality is needed when an item should receive the focus.

protected virtual void OnAccessKey(RoutedEventArgs e)

Parameters

e RoutedEventArgs

AccessKeyEventArgs are passed on to indicate if there are multiple matches or not.

OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs)

Calls the OnAttachedToVisualTree(VisualTreeAttachmentEventArgs) method for this control and all of its visual descendants.

protected override void OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs e)

Parameters

e VisualTreeAttachmentEventArgs

The event args.

OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs)

Calls the OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs) method for this control and all of its visual descendants.

protected override void OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs e)

Parameters

e VisualTreeAttachmentEventArgs

The event args.

OnGotFocus(GotFocusEventArgs)

Called before the GotFocus event occurs.

protected virtual void OnGotFocus(GotFocusEventArgs e)

Parameters

e GotFocusEventArgs

The event args.

OnKeyDown(KeyEventArgs)

Called before the KeyDown event occurs.

protected virtual void OnKeyDown(KeyEventArgs e)

Parameters

e KeyEventArgs

The event args.

OnKeyUp(KeyEventArgs)

Called before the KeyUp event occurs.

protected virtual void OnKeyUp(KeyEventArgs e)

Parameters

e KeyEventArgs

The event args.

OnLostFocus(RoutedEventArgs)

Called before the LostFocus event occurs.

protected virtual void OnLostFocus(RoutedEventArgs e)

Parameters

e RoutedEventArgs

The event args.

OnPointerCaptureLost(PointerCaptureLostEventArgs)

Called before the PointerCaptureLost event occurs.

protected virtual void OnPointerCaptureLost(PointerCaptureLostEventArgs e)

Parameters

e PointerCaptureLostEventArgs

The event args.

OnPointerEntered(PointerEventArgs)

Called before the PointerEntered event occurs.

protected virtual void OnPointerEntered(PointerEventArgs e)

Parameters

e PointerEventArgs

The event args.

OnPointerExited(PointerEventArgs)

Called before the PointerExited event occurs.

protected virtual void OnPointerExited(PointerEventArgs e)

Parameters

e PointerEventArgs

The event args.

OnPointerMoved(PointerEventArgs)

Called before the PointerMoved event occurs.

protected virtual void OnPointerMoved(PointerEventArgs e)

Parameters

e PointerEventArgs

The event args.

OnPointerPressed(PointerPressedEventArgs)

Called before the PointerPressed event occurs.

protected virtual void OnPointerPressed(PointerPressedEventArgs e)

Parameters

e PointerPressedEventArgs

The event args.

OnPointerReleased(PointerReleasedEventArgs)

Called before the PointerReleased event occurs.

protected virtual void OnPointerReleased(PointerReleasedEventArgs e)

Parameters

e PointerReleasedEventArgs

The event args.

OnPointerWheelChanged(PointerWheelEventArgs)

Called before the PointerWheelChanged event occurs.

protected virtual void OnPointerWheelChanged(PointerWheelEventArgs e)

Parameters

e PointerWheelEventArgs

The event args.

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

OnTextInput(TextInputEventArgs)

Called before the TextInput event occurs.

protected virtual void OnTextInput(TextInputEventArgs e)

Parameters

e TextInputEventArgs

The event args.

UpdateIsEffectivelyEnabled()

Updates the IsEffectivelyEnabled property value according to the parent control's enabled state and IsEnabledCore.

protected void UpdateIsEffectivelyEnabled()

Events

DoubleTapped

Occurs when a double-tap gesture occurs on the control.

public event EventHandler<TappedEventArgs>? DoubleTapped

Event Type

EventHandler<TappedEventArgs>

GotFocus

Occurs when the control receives focus.

public event EventHandler<GotFocusEventArgs>? GotFocus

Event Type

EventHandler<GotFocusEventArgs>

Holding

Occurs when a hold gesture occurs on the control.

public event EventHandler<HoldingRoutedEventArgs>? Holding

Event Type

EventHandler<HoldingRoutedEventArgs>

KeyDown

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

public event EventHandler<KeyEventArgs>? KeyDown

Event Type

EventHandler<KeyEventArgs>

KeyUp

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

public event EventHandler<KeyEventArgs>? KeyUp

Event Type

EventHandler<KeyEventArgs>

LostFocus

Occurs when the control loses focus.

public event EventHandler<RoutedEventArgs>? LostFocus

Event Type

EventHandler<RoutedEventArgs>

PointerCaptureLost

Occurs when the control or its child control loses the pointer capture for any reason, event will not be triggered for a parent control if capture was transferred to another child of that parent control

public event EventHandler<PointerCaptureLostEventArgs>? PointerCaptureLost

Event Type

EventHandler<PointerCaptureLostEventArgs>

PointerEntered

Occurs when the pointer enters the control.

public event EventHandler<PointerEventArgs>? PointerEntered

Event Type

EventHandler<PointerEventArgs>

PointerExited

Occurs when the pointer leaves the control.

public event EventHandler<PointerEventArgs>? PointerExited

Event Type

EventHandler<PointerEventArgs>

PointerMoved

Occurs when the pointer moves over the control.

public event EventHandler<PointerEventArgs>? PointerMoved

Event Type

EventHandler<PointerEventArgs>

PointerPressed

Occurs when the pointer is pressed over the control.

public event EventHandler<PointerPressedEventArgs>? PointerPressed

Event Type

EventHandler<PointerPressedEventArgs>

PointerReleased

Occurs when the pointer is released over the control.

public event EventHandler<PointerReleasedEventArgs>? PointerReleased

Event Type

EventHandler<PointerReleasedEventArgs>

PointerWheelChanged

Occurs when the mouse is scrolled over the control.

public event EventHandler<PointerWheelEventArgs>? PointerWheelChanged

Event Type

EventHandler<PointerWheelEventArgs>

Tapped

Occurs when a tap gesture occurs on the control.

public event EventHandler<TappedEventArgs>? Tapped

Event Type

EventHandler<TappedEventArgs>

TextInput

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

public event EventHandler<TextInputEventArgs>? TextInput

Event Type

EventHandler<TextInputEventArgs>

TextInputMethodClientRequested

Occurs when an input element gains input focus and input method is looking for the corresponding client

public event EventHandler<TextInputMethodClientRequestedEventArgs>? TextInputMethodClientRequested

Event Type

EventHandler<TextInputMethodClientRequestedEventArgs>