Module Text
Component to handle all GUI texts.
Druid text can adjust itself for text node size
Text will never will be outside of his text size (even multiline)
init(self, node[, value[, adjust_type=0]]) |
Component init function |
get_text_width(self[, text]) |
Calculate text width with font with respect to trailing space |
set_to(self, set_to) |
Set text to text field |
set_color(self, color) |
Set color |
set_alpha(self, alpha) |
Set alpha |
set_scale(self, scale) |
Set scale |
set_pivot(self, pivot) |
Set text pivot. |
is_multiline(self) |
Return true, if text with line break |
set_text_adjust(self[, adjust_type[, minimal_scale]]) |
Set text adjust, refresh the current text visuals, if needed |
set_minimal_scale(self, minimal_scale) |
Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types |
get_text_adjust(self, adjust_type) |
Return current text adjust type |
style |
Component style params. |
-
init(self, node[, value[, adjust_type=0]])
-
Component init function
Parameters:
- self
Text
- node
node
Gui text node
- value
string
Initial text. Default value is node text from GUI scene.
(optional)
- adjust_type
int
Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
(default 0)
-
get_text_width(self[, text])
-
Calculate text width with font with respect to trailing space
Parameters:
- self
Text
- text
string
(optional)
-
set_to(self, set_to)
-
Set text to text field
Parameters:
- self
Text
- set_to
string
Text for node
Returns:
Text
Current text instance
-
set_color(self, color)
-
Set color
Parameters:
- self
Text
- color
vector4
Color for node
Returns:
Text
Current text instance
-
set_alpha(self, alpha)
-
Set alpha
Parameters:
- self
Text
- alpha
number
Alpha for node
Returns:
Text
Current text instance
-
set_scale(self, scale)
-
Set scale
Parameters:
- self
Text
- scale
vector3
Scale for node
Returns:
Text
Current text instance
-
set_pivot(self, pivot)
-
Set text pivot. Text will re-anchor inside text area
Parameters:
- self
Text
- pivot
gui.pivot
Gui pivot constant
Returns:
Text
Current text instance
-
is_multiline(self)
-
Return true, if text with line break
Parameters:
Returns:
bool
Is text node with line break
-
set_text_adjust(self[, adjust_type[, minimal_scale]])
-
Set text adjust, refresh the current text visuals, if needed
Parameters:
- self
Text
- adjust_type
number
See const.TEXT_ADJUST. If pass nil - use current adjust type
(optional)
- minimal_scale
number
If pass nil - not use minimal scale
(optional)
Returns:
Text
Current text instance
-
set_minimal_scale(self, minimal_scale)
-
Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
Parameters:
- self
Text
- minimal_scale
number
If pass nil - not use minimal scale
Returns:
Text
Current text instance
-
get_text_adjust(self, adjust_type)
-
Return current text adjust type
Parameters:
Returns:
number
The current text adjust type
-
style
-
Component style params.
You can override this component styles params in druid styles table
or create your own style
Fields:
- TRIM_POSTFIX
string
The postfix for TRIM adjust type
(default ...)
- DEFAULT_ADJUST
string
The default adjust type for any text component
(default DOWNSCALE)
-
on_set_text
-
On set text callback(self, text)
-
on_update_text_scale
-
On adjust text size callback(self, new_scale)
- on_update_text_scale
druid_event
-
on_set_pivot
-
On change pivot callback(self, pivot)
-
node
-
Text node
-
node_id
-
The node id of text node
-
pos
-
Current text position
-
start_scale
-
Initial text node scale
-
scale
-
Current text node scale
-
start_size
-
Initial text node size
-
text_area
-
Current text node available are
-
adjust_type
-
Current text size adjust settings
-
color
-
Current text color