API:ButtonSetTextColor
From RoR Wiki
UI Lua API · Button functions
Version: WAR 1.4.8
Sets the text colour a Button uses in one of its states.
ButtonSetTextColor(buttonName, state, r, g, b)
Arguments
- buttonName
string– Name of a Button window.- state
number– The button state, one of theButton.ButtonStatevalues below.- r, g, b
number– Red, green and blue on a 0–255 scale.
Returns
Nothing.
Details
- A button keeps a separate text colour for each of its six states. The client defines these constants:
| Constant | Value | Used when |
|---|---|---|
Button.ButtonState.NORMAL |
0 | none of the flags below |
Button.ButtonState.PRESSED |
1 | pressed |
Button.ButtonState.DISABLED |
2 | disabled, not pressed |
Button.ButtonState.HIGHLIGHTED |
3 | highlighted, not pressed, not disabled |
Button.ButtonState.PRESSED_HIGHLIGHTED |
4 | highlighted and pressed, not disabled |
Button.ButtonState.DISABLED_PRESSED |
5 | disabled and pressed |
- Each colour component is converted to a whole number by dropping the fractional part, then divided by 255. Alpha is always set to fully opaque; the text's alpha follows the button's opacity.
- After the colour is stored, the button's text is redrawn with the colour of its current state.
stateis not range-checked. Use only the six values above.
Errors
Error in function call 'ButtonSetTextColor': Window %s does not existError in function call 'ButtonSetTextColor': Window %s is not a Button
Example
Giving a chat channel button the channel's colour in every state, from ea_chatwindow/source/chatwindow.lua:
ButtonSetTextColor("ChatChannelSelectionWindowSayButton", Button.ButtonState.NORMAL, channelColor.r, channelColor.g, channelColor.b)
ButtonSetTextColor("ChatChannelSelectionWindowSayButton", Button.ButtonState.HIGHLIGHTED, channelColor.r, channelColor.g, channelColor.b)
ButtonSetTextColor("ChatChannelSelectionWindowSayButton", Button.ButtonState.PRESSED, channelColor.r, channelColor.g, channelColor.b)
ButtonSetTextColor("ChatChannelSelectionWindowSayButton", Button.ButtonState.PRESSED_HIGHLIGHTED, channelColor.r, channelColor.g, channelColor.b)
