This function creates a text field within the current debug section.
By default, the text input modifies the variable referenced as a string variable. You can change this data type by setting the optional type parameter to one of the following values:
The text field also accepts hexadecimal and binary as input for both integers and real numbers, i.e. 0xcafebabe or 0b1010101. It converts this input to the correct value for the given data type.
WARNING If the variable referenced stores a value of a different type than the type you provide to this function, any change you make to the text will change the referenced variable's type.
NOTE This debug control spans two columns.
NOTE On Android, editing a text field will bring up the on-screen keyboard.
dbg_text_input(ref[, label, type]);
Argument | Type | Description |
---|---|---|
ref | Reference | A reference to a variable created using ref_create |
label | String | OPTIONAL The label to show next to the text input |
type | String | OPTIONAL The type to store the value as in the variable that's referenced. This is indicated by a single letter: - string: "s" or "t" (default) - integer: "i" or "d" - real: "f", "r" or "g" |
N/A
Create Event
description = "This description can be changed";
var _ref = ref_create(self, "description");
dbg_text_input(_ref, "Enter the description here:");
The above code first assigns some text to an instance variable description. It then creates a reference to this variable using ref_create. Next, it creates a text input control using dbg_text_input, the reference links the control to the variable.
Create Event
an_integer = 5;
a_real = 0.3583;
a_string = "3289430";
ref_to_count = ref_create(self, "an_integer");
ref_to_some_value = ref_create(self, "a_real");
ref_to_a_string = ref_create(self, "a_string");
dbg_text_input(ref_to_count, "An Integer", "i");
dbg_text_input(ref_to_some_value, "A Real", "f");
dbg_text_input(ref_to_a_string, "A String", "s");
Draw Event
draw_text(5, 600, $"An Integer ({typeof(an_integer)}): {an_integer}");
draw_text(5, 620, $"A Real ({typeof(a_real)}): {a_real}");
draw_text(5, 640, $"A String ({typeof(a_string)}): {a_string}");
This code example shows how to use custom data types with the text input debug control.
In the Create event of an object a couple of variables are first defined. They are assigned a real, another real and a string value. Then, a reference is created to each of these instance variables. After that, a text input is created using dbg_text_input to modify each of these variables through the reference to it. The function calls to dbg_text_input will bring up The Debug Overlay, so no call to show_debug_overlay is required.
In the object's Draw event a line of text is displayed using draw_text for each of the variables. Each line shows a descriptive text and the type of value between parentheses, followed by the value itself. Any change made in the text inputs will show in the drawn text.
Note that the type of the first variable changes immediately from "number" to "int64" as soon as you make a change in its text input control.