Table of Contents

Class InteractiveControl

Namespace
BSGameLib.UI.Controls.Base
Assembly
BSGameLib.UI.dll

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

logger ILogger
view View
id string

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

bool

HasFocus

Whether the control has keyboard focus. The root sets it as focus moves.

public bool HasFocus { get; }

Property Value

bool

IsHovered

Whether the pointer is over the control.

public bool IsHovered { get; }

Property Value

bool

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

bool

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

bool

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()

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

EventHandler

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

EventHandler

KeyDown

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

public event KeyboardEventHandler KeyDown

Event Type

KeyboardEventHandler

KeyPress

Raised for the key presses that type text, while the control has focus.

public event KeyboardEventHandler KeyPress

Event Type

KeyboardEventHandler

KeyUp

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

public event KeyboardEventHandler KeyUp

Event Type

KeyboardEventHandler

MouseClick

Raised when the control is clicked: pressed and released over it.

public event MouseEventHandler MouseClick

Event Type

MouseEventHandler

MouseDown

Raised when a mouse button is pressed over the control.

public event MouseEventHandler MouseDown

Event Type

MouseEventHandler

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

MouseEventHandler

MouseHover

Raised while the pointer is over the control.

public event MouseEventHandler MouseHover

Event Type

MouseEventHandler

MouseHoverEnter

Raised when the pointer moves onto the control.

public event MouseEventHandler MouseHoverEnter

Event Type

MouseEventHandler

MouseHoverLeave

Raised when the pointer moves off the control.

public event MouseEventHandler MouseHoverLeave

Event Type

MouseEventHandler

MouseUp

Raised when a mouse button is released over the control.

public event MouseEventHandler MouseUp

Event Type

MouseEventHandler