API:ColorPickerGetColorAtPoint
From RoR Wiki
UI Lua API · ColorPicker functions
Version: WAR 1.4.8
Returns the colour swatch under a point of a ColorPicker.
color = ColorPickerGetColorAtPoint(colorPickerName, x, y)
Arguments
- colorPickerName
string– Name of the ColorPicker.- x, y
number– The point, in the same coordinates that the ColorPicker's mouse event handlers (for exampleOnLButtonUp( flags, x, y )) receive.
Returns
- color
table– The swatch at the point, or nothing if there is none. Fields:
| Key | Type | Meaning |
|---|---|---|
r, g, b |
number |
Colour components, 0–255. |
id |
number |
The id given when the colour was added. |
x, y |
number |
The swatch's position in the picker, in unscaled pixels. |
Details
- When no swatch is at the point, the function returns no value, so
colorisnil. Test for that before using it. - Swatches are checked in the order they were added; the first one containing the point is returned.
Errors
Error in function call 'ColorPickerGetColorAtPoint': Window %s does not existError in function call 'ColorPickerGetColorAtPoint': Window %s is not a ColorPicker
Example
From ChatOptionsWindow.OnLButtonUpColorPicker in default/ea_chatwindow/source/chatoptionswindow.lua:
local color = ColorPickerGetColorAtPoint( "ChatOptionsWindowColorPicker", x, y )
if (color ~= nil)
then
LabelSetTextColor("ChatOptionsWindowListRow"..ChatOptionsWindow.SelectedMessageTypeWindowIndex.."ChannelName",
color.r,
color.g,
color.b)
end
