Class InteractiveControl
The base of a control the player can point at, click or type into. Its events report what the player did to it.
public abstract class InteractiveControl : UIElement, IUpdateable, IEquatable<IUpdateable>, IDrawable, IIdentifiable<Guid>, IEquatable<IDrawable>, IDisposable
- Inheritance
-
InteractiveControl
- Implements
- Derived
- Inherited Members
Constructors
InteractiveControl(ILogger, View, string)
Creates an interactive control in view.
protected InteractiveControl(ILogger logger, View view, string id = null)
Parameters
Properties
CanFocus
Whether this control can take keyboard focus - be tabbed to, clicked into, or chosen as a view's first focus. True for every interactive control unless it says otherwise; a control that takes no input of its own worth focusing (a list that only displays) overrides it. Such a control still gets the mouse - hover, the scroll wheel - it just isn't a stop in the focus ring.
public virtual bool CanFocus { get; }
Property Value
HasFocus
Whether the control has keyboard focus. The root sets it as focus moves.
public bool HasFocus { get; }
Property Value
IsHovered
Whether the pointer is over the control.
public bool IsHovered { get; }
Property Value
RequiresRawKeyboard
Whether the control takes the keys a view would otherwise use for itself, such as the arrow keys and Enter. A text box and a slider do.
public virtual bool RequiresRawKeyboard { get; }
Property Value
SuppressesDefaultButton
True while this control needs Enter for itself, so the view's default button must not also fire.
public virtual bool SuppressesDefaultButton { get; }
Property Value
Remarks
Deliberately not "did the control mark the key handled": a TextBox handles Enter to commit its value and blur, and a form should still submit from there - that is the whole point of pressing Enter in a text field. Only a control that genuinely consumes Enter, like an open dropdown choosing a row, opts out.
Methods
GainFocus()
Called by the root when the control gets focus. Sets HasFocus.
public virtual void GainFocus()
LoseFocus()
Called by the root when the control loses focus. Clears HasFocus.
public virtual void LoseFocus()
ReleaseFocus()
Asks to be blurred. See FocusReleaseRequested.
protected void ReleaseFocus()
RequestFocus()
Raises FocusRequested.
protected void RequestFocus()
Events
FocusReleaseRequested
Raised when a control wants to stop being the focused one - a TextBox committing on Enter, say.
public event EventHandler FocusReleaseRequested
Event Type
Remarks
Exists because a control must never blur itself. BSGameLib.UI.UIRoot owns which control has focus, and calling LoseFocus() directly changes the control's mind without changing the root's: the root goes on believing this control is focused, so the next click on it is swallowed by the "already focused, nothing to do" check and focus can never come back. That was a real, reported bug - the password field on Odyssey's offline login screen could not be clicked into again after Enter until some other field had been clicked first, which is what finally moved the root's idea of focus. Ask, don't act; the root does the acting.
FocusRequested
Raised when the control wants focus. The root decides whether to move it there.
public event EventHandler FocusRequested
Event Type
KeyDown
Raised when a key is pressed while the control has focus.
public event KeyboardEventHandler KeyDown
Event Type
KeyPress
Raised for the key presses that type text, while the control has focus.
public event KeyboardEventHandler KeyPress
Event Type
KeyUp
Raised when a key is released while the control has focus.
public event KeyboardEventHandler KeyUp
Event Type
MouseClick
Raised when the control is clicked: pressed and released over it.
public event MouseEventHandler MouseClick
Event Type
MouseDown
Raised when a mouse button is pressed over the control.
public event MouseEventHandler MouseDown
Event Type
MouseDrag
Raised every frame after MouseDown while the button stays held, wherever the pointer is - outside this control's bounds included, so a slider dragged past its end keeps tracking and pins at the end rather than stopping short of it.
public event MouseEventHandler MouseDrag
Event Type
MouseHover
Raised while the pointer is over the control.
public event MouseEventHandler MouseHover
Event Type
MouseHoverEnter
Raised when the pointer moves onto the control.
public event MouseEventHandler MouseHoverEnter
Event Type
MouseHoverLeave
Raised when the pointer moves off the control.
public event MouseEventHandler MouseHoverLeave
Event Type
MouseUp
Raised when a mouse button is released over the control.
public event MouseEventHandler MouseUp