Defines cwLabelButton, a DLabel that works as a button with hovered, depressed and disabled states and an optional background box.

Has FadeIn and FadeOut animations that play the theme's click and rollover sounds, OverrideTextColor, and SetCallback to set the click handler. The character menu and the quiz use it for their buttons.

Summary

Methods

Shows the label and starts fading it in, playing the click sound.
Starts fading the label out and hiding it, playing the rollover sound.
Returns whether the label is held down.
Returns whether the label is disabled.
Returns whether the label is hovered.
Marks the label as hovered unless it is disabled.
Clears the label's hovered state.
Captures the mouse and marks the label as held down.
Releases the mouse and calls DoClick when the left button is released over an enabled label.
Sets a text color that replaces the default white, with a darker variant used when hovered or disabled.
Draws the background box, when enabled, lighter while hovered.
Sets the size of the background box, or makes it follow the text size.
Sets the function called when the label is clicked, playing the click sound first.
Sets whether the label is held down.
Sets whether the label ignores hovering and clicks and is drawn greyed out.
Sets whether a translucent box is drawn behind the label.
Sets whether the label is hovered.
Think()client
Runs the fade animation, sizes the label to its background box and colors the text for its disabled, hovered or normal state.

Methods

Shows the label and starts fading it in, playing the click sound.

Parameters

  • speed Number Length of the fade in seconds
  • Callback Function optional, defaults to nil Called once the label is fully visible

PANEL:FadeOut(speed, Callback)

client gamemodes/catwork/gamemode/core/derma/cl_labelbutton.lua:118

Starts fading the label out and hiding it, playing the rollover sound.

Parameters

  • speed Number Length of the fade in seconds
  • Callback Function optional, defaults to nil Called once the label is hidden

Returns whether the label is held down.

Returns

  • Boolean Whether the label is held down

Returns whether the label is disabled.

Returns

  • Boolean Whether the label is disabled

Returns whether the label is hovered.

Returns

  • Boolean Whether the label is hovered

Marks the label as hovered unless it is disabled.

Clears the label's hovered state.

Captures the mouse and marks the label as held down.

Parameters

  • code

Releases the mouse and calls DoClick when the left button is released over an enabled label.

Parameters

  • code

PANEL:OverrideTextColor(color)

client gamemodes/catwork/gamemode/core/derma/cl_labelbutton.lua:166

Sets a text color that replaces the default white, with a darker variant used when hovered or disabled.

Parameters

  • color Color Text color, or nil/false to use the default colors

Draws the background box, when enabled, lighter while hovered.

Parameters

  • w
  • h

Sets the size of the background box, or makes it follow the text size.

Parameters

  • w Number optional, defaults to nil Width of the box; leave out with h to fit the text
  • h Number optional, defaults to nil Height of the box; leave out with w to fit the text

Sets the function called when the label is clicked, playing the click sound first.

Parameters

  • Callback Function Called with the label

Sets whether the label is held down.

Parameters

  • depressed Boolean true while the mouse button is held on it

Sets whether the label ignores hovering and clicks and is drawn greyed out.

Parameters

  • disabled Boolean true to disable the label

PANEL:SetDrawBackground(bDraw)

client gamemodes/catwork/gamemode/core/derma/cl_labelbutton.lua:65

Sets whether a translucent box is drawn behind the label.

Parameters

  • bDraw Boolean optional, defaults to false true to draw the box

Sets whether the label is hovered.

Parameters

  • hovered Boolean true while the cursor is over it

Runs the fade animation, sizes the label to its background box and colors the text for its disabled, hovered or normal state.

Defined in