Skip to main content

HoverText

Based on game build 722832 | Last updated: 2026-04-28

Overview

HoverText is a UI widget extending Widget. It renders primary and secondary text strings that track the mouse position, automatically clamping to screen edges to prevent overflow. It integrates with the player's HUD and PlayerController to display context-sensitive action strings (LMB/RMB), tooltip data, and item status colors (e.g., wet vs. normal). Typically instantiated as a child of the player's HUD screen.

Usage example

local HoverText = require("widgets/hoverer")

-- Inside a HUD screen constructor:
self.hover = self:AddChild(HoverText(ThePlayer))
self.hover:SetPosition(0, 0, 0)
self.hover:FollowMouseConstrained()

-- Force text position settlement on move (optional hack for inspecting):
self.hover:ForceSettleTextPositionOnMove(true)

Dependencies & tags

External dependencies:

  • widgets/widget -- Widget base class
  • widgets/text -- Text child widget for rendering strings
  • constants -- Defines WET_TEXT_COLOUR, NORMAL_TEXT_COLOUR, CONTROL_PRIMARY, etc.
  • TheInput -- Global input manager for mouse position and control bindings
  • TheSim -- Screen size retrieval for clamping logic

Components used:

  • playercontroller (on owner) -- Accessed via owner.components.playercontroller for action strings and mouse state.
  • inspectable (on targets) -- Checked via lmb.target.components.inspectable for profile stats.
  • stackable (on targets) -- Accessed via lmb.target.replica.stackable for stack size display.

Tags: None identified.

Properties

PropertyTypeDefault ValueDescription
ownerentity---The player entity owning this widget; source for HUD controls and actions.
textText---Primary text child widget; displays the main tooltip or action string.
secondarytextText---Secondary text child widget; displays RMB action or cancel hint.
isFEbooleanfalseToggles between Front End mode (uses owner:GetTooltipPos) and In-Game mode (uses HUD.controls).
default_text_posVector3(0, 40, 0)Fallback position if tooltip position calculation fails.
force_settle_textbooleannilIf true, SettleTextPosition is called during UpdatePosition.
followhandlerhandlernilReference to the input move handler registered by FollowMouseConstrained.
strstringnilCurrent primary string content being displayed.
secondarystrstringnilCurrent secondary string content being displayed.
lastStrstring""Tracks previous string to detect changes for throttling.
strFramesnumber0Frame counter for SHOW_DELAY throttling logic.
forcehidebooleannilIf true, prevents Show() even if OnUpdate conditions are met.
YOFFSETUPconstant (local)-80Vertical offset for upper screen bound clamping in UpdatePosition().
YOFFSETDOWNconstant (local)-50Vertical offset for lower screen bound clamping in UpdatePosition().
XOFFSETconstant (local)10Horizontal offset for screen edge clamping in UpdatePosition().
SHOW_DELAYconstant (local)0Frame delay threshold for text change throttling in OnUpdate().

Main functions

_ctor(owner)

  • Description: Initialises the widget, calls Widget._ctor, creates text and secondarytext children, and starts the update loop.
  • Parameters:
    • owner -- Player entity instance; used to access HUD controls and PlayerController.
  • Returns: nil
  • Error states: Errors if owner is nil or lacks required HUD/Component structure (unguarded access in OnUpdate).

OnUpdate()

  • Description: Widget lifecycle. Called every frame while widget is active. Determines visibility, fetches tooltip/action strings from owner, calculates text colors based on target state (wet/normal), and updates text content. Throttles text changes via strFrames to prevent flickering.
  • Parameters: None
  • Returns: None
  • Error states: Errors if owner.HUD or owner.HUD.controls is nil in non-FE mode (no nil guard before access).

UpdatePosition(x, y)

  • Description: Calculates the widget's screen position based on mouse coordinates x, y. Clamps position to ensure text bounds stay within screen edges (TheSim:GetScreenSize), accounting for text region size and scale. Calls SettleTextPosition if force_settle_text is true.
  • Parameters:
    • x -- number screen X coordinate
    • y -- number screen Y coordinate
  • Returns: None
  • Error states: None

SettleTextPosition()

  • Description: Updates the internal text child position based on isFE mode. In FE mode, uses owner:GetTooltipPos(); in Game mode, uses owner.HUD.controls:GetTooltipPos().
  • Parameters: None
  • Returns: None
  • Error states: Errors if owner.HUD.controls is nil in Game mode.

ForceSettleTextPositionOnMove(boolval)

  • Description: Sets the force_settle_text flag. Used as a hack for specific UI states (e.g., UpgradeModulesDisplay_Inspecting) to override standard tooltip positioning logic during movement.
  • Parameters:
    • boolval -- boolean to enable or disable forced settling
  • Returns: None
  • Error states: None.

FollowMouseConstrained()

  • Description: Registers a global input move handler via TheInput:AddMoveHandler that calls UpdatePosition on mouse move. Initializes position immediately. Ensures only one handler is registered (followhandler check).
  • Parameters: None
  • Returns: None
  • Error states: None.

Events & listeners

None — Widget uses global TheInput handlers instead of entity events.