FocusRing class
Namespace: Arlecchino.Focus · Assembly: Arlecchino
The cycle of focusable elements inside one view: Tab and Shift+Tab move between them, and everything else goes to the one holding the focus. A ring is itself focusable, so rings nest.
public sealed class FocusRing : IArlecchinoFocusable
Implements IArlecchinoFocusable
Constructors
| Member | Summary |
|---|---|
FocusRing(ArlecchinoKeymap) | Creates an empty ring. |
Properties
| Member | Summary |
|---|---|
Current | The focused element, or null when the ring is empty. |
Index | Position of the focused element. |
IsFocused | Whether the ring itself holds the focus, which a view's own ring does from the start. It passes that on to the element it left the focus with, so nothing inside an unfocused ring draws as active. |
Items | The elements, in the order they were added. |
Methods
| Member | Summary |
|---|---|
Add(IArlecchinoFocusable) | Adds an element. The first one added starts focused. |
Focus(IArlecchinoFocusable) | Moves the focus to a particular element, if it belongs to this ring. |
FocusNext() | Moves the focus to the next element, wrapping around at the end. |
FocusPrevious() | Moves the focus to the previous element, wrapping around at the start. |
Handle(KeyPress) | Moves the focus on the field keys, and otherwise hands the key to the focused element. |
HandleMouse(MouseEvent) | Offers the event to each element and moves the focus to whichever one claims it, so a click both selects a pane and acts inside it. |
Hints() | What the focused element wants the hints box to show, asked down the chain: a ring answers for the ring inside it, which answers for the widget inside that. |
MoveFocus(FocusDirection) | Moves the focus one element along without wrapping, for a ring nested in another one. At either end the step is left to the ring outside, and this one keeps its place. |
Constructors in detail
FocusRing(ArlecchinoKeymap)
public FocusRing(ArlecchinoKeymap keymap);
Creates an empty ring.
Parameters
| Name | Type | Description |
|---|---|---|
keymap | ArlecchinoKeymap | Where the keys that move the focus come from. |
Properties in detail
Current
public IArlecchinoFocusable? Current { get; }
The focused element, or null when the ring is empty.
Type IArlecchinoFocusable
Index
public int Index { get; }
Position of the focused element.
Type int
IsFocused
public bool IsFocused { get; set; }
Whether the ring itself holds the focus, which a view's own ring does from the start. It passes that on to the element it left the focus with, so nothing inside an unfocused ring draws as active.
Type bool
Items
public IReadOnlyList<IArlecchinoFocusable> Items { get; }
The elements, in the order they were added.
Type IReadOnlyList<T><IArlecchinoFocusable>
Methods in detail
Add(IArlecchinoFocusable)
public void Add(IArlecchinoFocusable item);
Adds an element. The first one added starts focused.
Parameters
| Name | Type | Description |
|---|---|---|
item | IArlecchinoFocusable | The element to add. |
Focus(IArlecchinoFocusable)
public void Focus(IArlecchinoFocusable item);
Moves the focus to a particular element, if it belongs to this ring.
Parameters
| Name | Type | Description |
|---|---|---|
item | IArlecchinoFocusable | The element to focus. |
FocusNext()
public void FocusNext();
Moves the focus to the next element, wrapping around at the end.
FocusPrevious()
public void FocusPrevious();
Moves the focus to the previous element, wrapping around at the start.
Handle(KeyPress)
public ViewRoute Handle(KeyPress key);
Moves the focus on the field keys, and otherwise hands the key to the focused element.
Parameters
| Name | Type | Description |
|---|---|---|
key | KeyPress | The key that was pressed. |
Returns ViewRoute — The route the element asked for, or ViewRoute.None.
HandleMouse(MouseEvent)
public ViewRoute HandleMouse(MouseEvent mouse);
Offers the event to each element and moves the focus to whichever one claims it, so a click both selects a pane and acts inside it.
Parameters
| Name | Type | Description |
|---|---|---|
mouse | MouseEvent | The event, in frame coordinates. |
Returns ViewRoute — The route the element asked for, or ViewRoute.None.
Hints()
public ValueTuple<string, string>[] Hints();
What the focused element wants the hints box to show, asked down the chain: a ring answers for the ring inside it, which answers for the widget inside that.
Returns ValueTuple<T1, T2><string, string>[] — The hints of the focused element, empty when there are none.
MoveFocus(FocusDirection)
public bool MoveFocus(FocusDirection direction);
Moves the focus one element along without wrapping, for a ring nested in another one. At either end the step is left to the ring outside, and this one keeps its place.
Parameters
| Name | Type | Description |
|---|---|---|
direction | FocusDirection | Which way the focus is going. |
Returns bool — Whether the focus moved inside this ring.