cityrpTooltip

Generic information panel.

The tooltip system can be used on any panel or entity you would like to show standardized information for. Tooltips consist of the parent container panel (cityrpTooltip), which is filled with rows of information (usually cityrpTooltipRow, but can be any docked panel if non-text information needs to be shown, like an item's size).

Tooltips can be added to panel with panel:SetCityrpTooltip(). An example taken from the scoreboard:

panel:SetCityrpTooltip(function(tooltip)
    local name = tooltip:AddRow("name")
    name:SetImportant()
    name:SetText(client:SteamName())
    name:SetBackgroundColor(team.GetColor(client:Team()))
    name:SizeToContents()

    tooltip:SizeToContents()
end)

Functions

cityrpTooltip:AddRow(id)

View source »

Creates a new cityrpTooltipRow panel and adds it to the bottom of this tooltip.

Parameters

  • id string

    Name of the new row. This is used to reorder rows if needed

Returns

  • panel

    Created row

cityrpTooltip:AddRowAfter(after, id)

View source »

Creates a new cityrpTooltipRow and adds it after the row with the given id. The order of the rows is set via setting the Z position of the panels, as this is how VGUI handles ordering with docked panels.

Parameters

  • after string

    Name of the row to insert after

  • id string

    Name of the newly created row

Returns

  • panel

    Created row

cityrpTooltip:GetCursorPosition()

View source »

Returns the current position of the mouse cursor on the screen.

Returns

  • number

    X position of cursor

  • number

    Y position of cursor

cityrpTooltip:GetRow(id)

View source »

Returns an cityrpTooltipRow corresponding to the given name.

Parameters

Returns

  • panel

    Corresponding row

  • OR
  • nil

    If the row doesn't exist

cityrpTooltip:IsMinimal()

View source »

Whether or not this tooltip should be displayed in a minimal format.

Returns

  • bool

    True if this tooltip should be displayed in a minimal format

See Also

cityrpTooltip:SetEntity(entity)

Internal

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

View source »

Sets the entity associated with this tooltip. Note that this function is not how you get entities to show tooltips.

Parameters

  • entity

cityrpTooltip:SizeToContents()

View source »

Resizes the tooltip to fit all of the child panels. You should always call this after you are done adding all of your rows.