Table of Contents

Class Tooltip

Namespace
MLEM.Ui.Elements
Assembly
MLEM.Ui.dll

A tooltip element for use inside of a UiSystem. A tooltip is a Panel with a custom cursor that always follows the position of the mouse. Tooltips can easily be configured to be hooked onto an element, causing them to appear when it is moused, and disappear when it is not moused anymore.

public class Tooltip : Panel, IGenericDataHolder
Inheritance
Tooltip
Implements
Inherited Members
Extension Methods

Constructors

Tooltip(TextCallback, Element)

Creates a new tooltip with the given settings

public Tooltip(Paragraph.TextCallback textCallback, Element elementToHover = null)

Parameters

textCallback Paragraph.TextCallback

The text to display on the tooltip

elementToHover Element

The element that should automatically cause the tooltip to appear and disappear when hovered and not hovered, respectively

Tooltip(string, Element)

Creates a new tooltip with the given settings

public Tooltip(string text = null, Element elementToHover = null)

Parameters

text string

The text to display on the tooltip

elementToHover Element

The element that should automatically cause the tooltip to appear and disappear when hovered and not hovered, respectively

Fields

AutoNavAnchor

The anchor that should be used when this tooltip is displayed using auto-nav mode. The AutoNavOffset will be applied.

public StyleProp<Anchor> AutoNavAnchor

Field Value

StyleProp<Anchor>

AutoNavOffset

The offset that this tooltip should have from the element snapped to when DisplayInAutoNavMode is true.

public StyleProp<Vector2> AutoNavOffset

Field Value

StyleProp<Vector2>

Delay

The amount of time that the mouse has to be over an element before it appears

public StyleProp<TimeSpan> Delay

Field Value

StyleProp<TimeSpan>

DisplayInAutoNavMode

Determines whether this tooltip should display when IsAutoNavMode is true, which is when the UI is being controlled using a keyboard or gamepad. If this tooltip is displayed in auto-nav mode, it will display below the selected element with the AutoNavOffset applied.

public bool DisplayInAutoNavMode

Field Value

bool

MouseAnchor

The anchor that should be used when this tooltip is displayed using the mouse. The MouseOffset will be applied.

public StyleProp<Anchor> MouseAnchor

Field Value

StyleProp<Anchor>

MouseOffset

The offset that this tooltip should have from the mouse position

public StyleProp<Vector2> MouseOffset

Field Value

StyleProp<Vector2>

Paragraphs

A list of Paragraph objects that this tooltip automatically manages. A paragraph that is contained in this list will automatically have the TooltipTextWidth and TooltipTextColor applied. To add a paragraph to both this list and to Children, use AddParagraph(Paragraph, int).

public readonly List<Paragraph> Paragraphs

Field Value

List<Paragraph>

UseAutoNavBehaviorForMouse

If this is true, and the mouse is used, the tooltip will attach to the hovered element in a static position using the AutoNavOffset and AutoNavAnchor properties, rather than following the mouse cursor exactly.

public StyleProp<bool> UseAutoNavBehaviorForMouse

Field Value

StyleProp<bool>

Properties

IsHidden

Set this property to true to cause this element to be hidden. Hidden elements don't receive input events, aren't rendered and don't factor into auto-anchoring.

public override bool IsHidden { get; }

Property Value

bool

ParagraphTextColor

The TextColor that this tooltip's Paragraphs should have

public StyleProp<Color> ParagraphTextColor { get; set; }

Property Value

StyleProp<Color>

ParagraphTextScale

The TextScale that this tooltip's Paragraphs should have

public StyleProp<float> ParagraphTextScale { get; set; }

Property Value

StyleProp<float>

ParagraphWidth

The width that this tooltip's Paragraphs should have

public StyleProp<float> ParagraphWidth { get; set; }

Property Value

StyleProp<float>

SnapPosition

The position that this tooltip should be following (or snapped to) instead of the ViewportMousePosition. If this value is unset, ViewportMousePosition will be used as the snap position. Note that MouseOffset is still applied with this value set. Note that, if UseAutoNavBehaviorForMouse is true, this value is ignored.

public virtual Vector2? SnapPosition { get; set; }

Property Value

Vector2?

Methods

AddParagraph(Paragraph, int)

Adds the given paragraph to this tooltip's managed Paragraphs list, as well as to its children using AddChild<T>(T, int). A paragraph that is contained in the Paragraphs list will automatically have the TooltipTextWidth and TooltipTextColor applied.

public Paragraph AddParagraph(Paragraph paragraph, int index = -1)

Parameters

paragraph Paragraph

The paragraph to add

index int

The index to add the child at, or -1 to add it to the end of the Children list

Returns

Paragraph

The added paragraph, for chaining

AddParagraph(TextCallback, int)

Adds a new paragraph with the given text callback to this tooltip's managed Paragraphs list, as well as to its children using AddChild<T>(T, int). A paragraph that is contained in the Paragraphs list will automatically have the TooltipTextWidth and TooltipTextColor applied.

public Paragraph AddParagraph(Paragraph.TextCallback text, int index = -1)

Parameters

text Paragraph.TextCallback

The text that the paragraph should display

index int

The index to add the child at, or -1 to add it to the end of the Children list

Returns

Paragraph

The created paragraph, for chaining

AddParagraph(string, int)

Adds a new paragraph with the given text to this tooltip's managed Paragraphs list, as well as to its children using AddChild<T>(T, int). A paragraph that is contained in the Paragraphs list will automatically have the TooltipTextWidth and TooltipTextColor applied.

public Paragraph AddParagraph(string text, int index = -1)

Parameters

text string

The text that the paragraph should display

index int

The index to add the child at, or -1 to add it to the end of the Children list

Returns

Paragraph

The created paragraph, for chaining

AddToElement(Element)

Adds this tooltip instance to the given Element, making it display when it is moused over

public void AddToElement(Element elementToHover)

Parameters

elementToHover Element

The element that should automatically cause the tooltip to appear and disappear when hovered and not hovered, respectively

Display(UiSystem, string)

Adds this tooltip to the given UiSystem and either displays it directly or starts the Delay timer.

public bool Display(UiSystem system, string name)

Parameters

system UiSystem

The system to add this tooltip to

name string

The name that this tooltip should use

Returns

bool

Whether this tooltip was successfully added, which is not the case if it is already being displayed currently.

ForceUpdateArea()

Forces this element's Area to be updated if it is not IsHidden. This method also updates all of this element's Children's areas.

public override void ForceUpdateArea()

InitStyle(UiStyle)

Initializes this element's StyleProp<T> instances using the ui system's UiStyle.

protected override void InitStyle(UiStyle style)

Parameters

style UiStyle

The new style

Remove()

Removes this tooltip from its UiSystem and resets the Delay timer, if there is one.

public void Remove()

SnapPositionToMouse()

Causes this tooltip's position to be snapped to the mouse position, or the element to snap to if DisplayInAutoNavMode is true, or the SnapPosition if set.

public void SnapPositionToMouse()

Update(GameTime)

Updates this element and all of its SortedChildren

public override void Update(GameTime time)

Parameters

time GameTime

The game's time