Skip to main content

FocusablePane class

Namespace: Arlecchino.Focus · Assembly: Arlecchino

Wraps delegates as a focusable element, for a view that keeps its logic in methods rather than in objects. That is how the file picker holds its list and the sidebar of places.

public sealed class FocusablePane : IArlecchinoFocusable

Implements IArlecchinoFocusable

Constructors

MemberSummary
FocusablePane(Func<KeyPress, FocusResult>, Func<MouseEvent, FocusResult>)Creates the element.

Properties

MemberSummary
IsFocusedWhether this element holds the focus.

Methods

MemberSummary
Handle(KeyPress)Passes the key to the delegate.
HandleMouse(MouseEvent)Passes the mouse event to the delegate, if one was given.

Constructors in detail

FocusablePane(Func<KeyPress, FocusResult>, Func<MouseEvent, FocusResult>)

public FocusablePane(
Func<KeyPress, FocusResult> handle,
Func<MouseEvent, FocusResult>? handleMouse = null);

Creates the element.

Parameters

NameTypeDescription
handleFunc<T, TResult><KeyPress, FocusResult>What to do with a key while focused.
handleMouseFunc<T, TResult><MouseEvent, FocusResult>What to do with a mouse event; omit to ignore the mouse.

Properties in detail

IsFocused

public bool IsFocused { get; set; }

Whether this element holds the focus.

Type bool

Methods in detail

Handle(KeyPress)

public FocusResult Handle(KeyPress key);

Passes the key to the delegate.

Parameters

NameTypeDescription
keyKeyPressThe key that was pressed.

Returns FocusResult — What the delegate decided.

HandleMouse(MouseEvent)

public FocusResult HandleMouse(MouseEvent mouse);

Passes the mouse event to the delegate, if one was given.

Parameters

NameTypeDescription
mouseMouseEventThe event, in frame coordinates.

Returns FocusResult — What the delegate decided, or ignored.