WidgetSpinBox Class
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScipt (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
Inherits: | Widget |
This class creates a spin box.
Usage Example#
This example illustrates creation of a spinbox via code.
// declaring editline and spinbox widgets
WidgetEditLine new_el;
WidgetSpinBox new_sb;
// callback to be fired on changing spinbox value
void sbChanged(WidgetSpinBox sb) {
// printing the current spinbox value to the console
log.message("Spinbox value changed: %d \n", sb.getValue());
sb.setFocus();
}
int init() {
// Write here code to be called on world initialization: initialize resources for your world scene during the world start.
// ...
// getting the GUI
Gui gui = engine.getGui();
// creating a new edit line and adding it to the GUI
new_el = new WidgetEditLine(gui);
gui.addChild(new_el, GUI_ALIGN_OVERLAP);
// setting widget's position
new_el.setPosition(100, 100);
// creating a spinbox with the specified min and max values and adding it to the GUI
new_sb = new WidgetSpinBox(gui, 0, 10);
gui.addChild(new_sb, GUI_ALIGN_OVERLAP);
// adding a callback to be fired on changing spinbox value
new_sb.setCallback(GUI_CHANGED, functionid(sbChanged), new_sb);
new_sb.setOrder(1);
// attaching the spinbox to the edit line
new_el.addAttach(new_sb);
// setting initial spinbox value to 5
new_sb.setValue(5);
return 1;
}
// ...
WidgetSpinBox Class
Members
static WidgetSpinBox ( Gui gui, int min = 0, int max = 100, int value = 0 ) #
Constructor. Creates a spinbox with given parameters and adds it to the specified GUI.Arguments
- Gui gui - GUI, to which the spinbox will belong.
- int min - Minimum value.
- int max - Maximum value.
- int value - Initial value.
static WidgetSpinBox ( int min = 0, int max = 100, int value = 0 ) #
Constructor. Creates a spinbox with given parameters and adds it to the Engine GUI.Arguments
- int min - Minimum value.
- int max - Maximum value.
- int value - Initial value.
void setMaxExpand ( int expand ) #
Sets the maximum value, up to which the upper limit of the range of the spinbox values can be expanded.Arguments
- int expand - Maximum value, up to which the spinbox upper limit can be raised.
int getMaxExpand ( ) #
Returns the current maximum value, up to which the upper limit of the range of the spinbox values can be expanded.The upper limit of the spinbox can be expanded only if the spinbox is attached
to an editline with the GUI_ATTACH_MAX_EXPAND flag.
Return value
Maximum value, up to which the spinbox upper limit can be raised.void setMaxValue ( int value ) #
Sets a maximum value of the spinbox.Arguments
- int value - Maximum value.
int getMaxValue ( ) #
Returns a maximum value of the spinbox.The value returned by this function may differ from the value set via setMaxValue().
See The setMaxExpand() function for more details.
Return value
Maximum value.void setMinExpand ( int expand ) #
Sets the minimum value, up to which the lower limit of the range of the spinbox values can be expanded.Arguments
- int expand - Minimum value, up to which the spinbox lower limit can be dropped.
int getMinExpand ( ) #
Returns the current minimum value, up to which the lower limit of the range of the spinbox values can be dropped.The lower limit of the spinbox can be expanded only if the spinbox is attached
to an editline with the GUI_ATTACH_MIN_EXPAND flag.
Return value
Minimum value, up to which the spinbox lower limit can be dropped.void setMinValue ( int value ) #
Sets a minimum value of the spinbox.Arguments
- int value - Minimum value.
int getMinValue ( ) #
Returns a minimum value of the spinbox.The value returned by this function may differ from the value set via setMinValue().
See The setMinExpand() function for more details.
Return value
Minimum valuevoid setValue ( int value ) #
Updates a current value of the spinbox.Arguments
- int value - New value.
int getValue ( ) #
Returns a current value of the spinbox.Return value
Current value.void setButtonColor ( vec4 color ) #
Sets the color for the widget's button.Arguments
- vec4 color - Four-component vector specifying the color in the RGBA format.
vec4 getButtonColor ( ) #
Returns the current color for the widget's button.Return value
Four-component vector specifying the color in the RGBA format.Last update:
2020-07-31
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)