Defines the cwFAButton panel, a button that draws a Font Awesome icon with an optional text label next to it.

The icon is drawn with cw.FontIcons:Draw and set up with SetIcon, SetIconSize and SetText; SetCallback sets what a click does. A collapsible button toggles between showing and hiding its text when clicked, and FadeIn and FadeOut animate its alpha. It is the base of the main menu's buttons, such as cw.menuButton.

Summary

Methods

Shows the button and starts fading it in, playing the click sound.
Starts fading the button out and hiding it, playing the rollover sound.
Toggles the button when it is collapsible and runs its callback, reporting any error it throws.
Sets a color that replaces the text and icon color, including the hover color.
Draws the background, when enabled, then the icon and text, highlighted when hovered.
Sets the function called when the button is clicked.
Sets whether clicking the button toggles it open and closed.
Sets whether the button draws its dark background box.
Sets the font of the button's text.
Sets the Font Awesome icon drawn on the button.
Sets the icon's size and offset.
Sets whether the button is open, which shows its text next to the icon.
Sets the button's text and makes it visible.
Sets the position of the text inside the button, replacing the default placement after the icon.
Sets whether the button highlights itself when hovered.
Resizes the button to fit its icon and text.
Think()client
Shows the text only while the button is open.
Toggle()client
Toggles whether the button is open.

Methods

PANEL:FadeIn(speed, Callback)

client gamemodes/catwork/gamemode/core/derma/cl_fabutton.lua:215

Shows the button 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 button is fully visible

PANEL:FadeOut(speed, Callback)

client gamemodes/catwork/gamemode/core/derma/cl_fabutton.lua:190

Starts fading the button 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 button is hidden

Toggles the button when it is collapsible and runs its callback, reporting any error it throws.

PANEL:OverrideTextColor(color)

client gamemodes/catwork/gamemode/core/derma/cl_fabutton.lua:238

Sets a color that replaces the text and icon color, including the hover color.

Parameters

  • color Color Color to use, or nil to use the default colors

Draws the background, when enabled, then the icon and text, highlighted when hovered.

Parameters

  • w
  • h

Sets the function called when the button is clicked.

Parameters

  • cb Function Called with the button; errors are caught and printed

Sets whether clicking the button toggles it open and closed.

Parameters

  • coll Boolean true to toggle on click

PANEL:SetDrawBackground(bDrawBackground)

client gamemodes/catwork/gamemode/core/derma/cl_fabutton.lua:30

Sets whether the button draws its dark background box.

Parameters

  • bDrawBackground Boolean true to draw the background

Sets the font of the button's text.

Parameters

  • font String Font name; Derma16 is used when unset

Aliases

  • PANEL.SetTextFont

Sets the Font Awesome icon drawn on the button.

Parameters

PANEL:SetIconSize(w, h, x, y)

client gamemodes/catwork/gamemode/core/derma/cl_fabutton.lua:45

Sets the icon's size and offset.

Parameters

  • w Number optional, defaults to 16 Icon width
  • h Number optional, defaults to 16 Icon height, also used as the icon's draw size
  • x Number optional, defaults to 0 Horizontal offset of the icon
  • y Number optional, defaults to 0 Vertical offset of the icon

Sets whether the button is open, which shows its text next to the icon.

Parameters

  • bIsOpen Boolean true to show the text

Sets the button's text and makes it visible.

Parameters

  • text String Text to draw

Sets the position of the text inside the button, replacing the default placement after the icon.

Parameters

  • x Number Horizontal offset
  • y Number Vertical offset

Sets whether the button highlights itself when hovered.

Parameters

  • hover Boolean true to highlight on hover

Resizes the button to fit its icon and text.

Aliases

  • PANEL.SizeToContents

Shows the text only while the button is open.

Toggles whether the button is open.

Defined in