Creating and placing GUI components is only the first step -- without interaction or dynamic behavior, they don't do much.
In this section, you'll learn how to set and retrieve the state of GUI components after placing them, such as reading text from a field or updating colors or graphics.
To change the color of a GUI component, use the setComponentColor function. Its format is as follows:
- Function Format -Arguments:
The color values follow the RGBA color model, which adds an alpha (transparency) component to the usual RGB (Red, Green, Blue). These values follow the properties below:
Note: Color blending is done using additive color mixing -- like how light works -- not subtractive mixing like paint. The result may differ significantly from what you might expect from pigment blending.
To get the current color settings of a GUI component, use the getComponentColor function:
- Function Format -Arguments:
Return value:
A 2x4 int array containing the RGBA values:
The "setComponentColor" and "getComponentColor" functions can be used with the following GUI components:
To change the position of a GUI component, use the "setComponentLocation" function:
- Function Format -Arguments:
To get the current position of a GUI component, use the "getComponentLocation" function:
- Function Format -Arguments:
Return value:
An int array of size 2:
These position functions can be used with the following GUI components:
To change the size of a GUI component, use the "setComponentSize" function:
- Function Format -Arguments:
To get the current size of a GUI component, use the getComponentSize function:
- Function Format -Arguments:
Return value:
An int array of size 2:
setComponentSizeおよびgetComponentSize関数は、以下のGUIコンポーネントなどに対して使用できます。
To change the text of a GUI component, use the setComponentText function:
- Function Format -Arguments:
To retrieve the text from a GUI component, use the "getComponentText" function:
- Function Format -Arguments:
Return value:
Returns the current text as a string.
The "setComponentText" and "getComponentText" functions can be used with the following GUI components:
For components that display graphics -- such as image labels -- you can change the displayed graphics resource by using the setComponentGraphics function:
- Function Format -Arguments:
To retrieve the ID of the graphics resource currently being displayed by a component, use the "getComponentGraphics" function:
- Function Format -Arguments:
Return value:
Returns the ID of the graphics resource currently displayed.
The "setComponentGraphics" and "getComponentGraphics" functions can be used with the following GUI components:
For components that have binary ON/OFF states -- such as check boxes -- use the setComponentBool function to set the value:
- Function Format -Arguments:
To retrieve a boolean value from a component, use the "getComponentBool" function:
- Function Format -Arguments:
Return value:
Returns the boolean state as a bool. For example, with a check box, it returns true if checked, and false otherwise.
The "setComponentBool" and "getComponentBool" functions can be used with the following GUI components:
Although not covered in this guide, some GUI components -- such as sliders -- allow control over other types of values such as "int" or "float".
These components can be handled using the same pattern, with functions like:
For details on these components and functions, please refer to the GUI Library Specification.