Authentic Native Textbox

Authentic Native Textbox creates native textboxes that are overlaid on top of the game. Because of this it's not possible to draw anything over them.

Textboxes are created in code and must be manually cleaned up. Textboxes will automatically launch the virtual keyboard whenever they are pressed and will handle copy/pasting, selections, and other various features you expect in textboxes on the native platforms.

To detect if the virtual keyboard is out you cannot use the inbuilt keyboard_virtual_status() as it will not detect if the keyboard was launched by a textbox. However keyboard_virtual_height() works as normal and can be used instead.

Table of contents

ant_textbox_create
ant_textbox_remove
ant_textbox_set_position
ant_textbox_set_text_size
ant_textbox_android_set_font
ant_textbox_ios_set_font
ant_textbox_set_style
ant_textbox_set_text
ant_textbox_get_text
ant_textbox_set_color
ant_textbox_focus
ant_textbox_unfocus
ant_textbox_is_focused
ant_textbox_has_submitted
ant_textbox_set_enabled
ant_textbox_set_focusable
ant_textbox_android_set_style
ant_textbox_ios_set_style
ant_textbox_ios_set_password

ant_textbox_create()

Returns: Created textbox

Creates a new textbox and returns it.

ant_textbox_remove(textbox)

Arguments

textbox Textbox to remove

Returns: 0 if successful, -1 if not

Removes the provided textbox

ant_textbox_set_position(textbox, x, y, width, height)

Arguments

textbox Textbox to apply to
x Position y in pixels
y Height in pixels
width Width in pixels
height Height in pixels

Returns: 0 if successful, -1 if not

Positions the provided textbox at the given location.

ant_textbox_set_text_size(textbox, size)

Arguments

textbox Textbox to apply to
size Size of the text inside the box in pts

Returns: 0 if successful, -1 if not

Sets the size of the text in the textbox. The value is in points and should match what the equivalent font is set to in GameMaker.

ant_textbox_android_set_font(textbox, font)

Arguments

textbox Textbox to apply to
font Name of the font to style the textbox with

Returns: 0 if successful, -1 if not

Sets what font the textbox should use on an Android system.

The available fonts are as follows

Identifier to provide Actual font
sans-serif-thin Roboto Thin
sans-serif-light Roboto Light
sans-serif Roboto Regular
sans-serif-medium Roboto Medium
sans-serif-black Roboto Black
sans-serif-condensed-light Roboto Condensed Light
sans-serif-condensed Roboto Condensed Regular
sans-serif-condensed-medium Roboto Condensed Medium
serif Noto Serif
monospace Droid Sans Mono
serif-monospace CutiveMono
cursive Dancing Script
sans-serif-smallcaps CarroisGothic SC

ant_textbox_ios_set_font(textbox, font)

Arguments

textbox Textbox to apply to
font Name of the font to style the textbox with

Returns: 0 if successful, -1 if not

Sets what font the textbox should use on an iOS system. The available fonts can be found here.

ant_textbox_set_style(textbox, type, capitalization, autocorrect)

Arguments

textbox Textbox to apply to
type Type of textbox this should be
capitalization Type of capitalization this textbox should use
autocorrect Type of autocorrect this textbox should use

Returns: 0 if successful, -1 if not

Sets the textbox's style on all platforms. This will replace anything previously set by the platform specific style functions. The function arguments expect macros.

This constant is used to decide what type of keyboard to show.

Keyboard type Description
ant_style_type_default Shows a default keyboard
ant_style_type_ascii Shows a keyboard with ascii only
ant_style_type_url Shows a keyboard for url input
ant_style_type_email Shows a keyboard for email input
ant_style_type_password Hides the entered text and does not allow copying
ant_style_type_numbers Shows a numberpad

This constant is used to determine how the text should be capitalized

Capitalization type Description
ant_style_capitalize_none Nothing is capitalized
ant_style_capitalize_words Words are capitalized
ant_style_capitalize_sentences Sentences are capitalized
ant_style_capitalize_all All text is capitalized

This constant determines if autocorrect should be enabled or not

Autocorrection type Description
ant_style_autocorrect_off Autocorrect is disabled
ant_style_autocorrect_on Autocorrect is enabled

ant_textbox_set_text(textbox, text)

Arguments

textbox Textbox to apply to
text Text to set inside the textbox

Returns: 0 if successful, -1 if not

Sets the text of the textbox to the provided string

ant_textbox_get_text(textbox)

Arguments

textbox Textbox to get text from

Returns: Text of the textbox

Gets the text currently inside the textbox as a string

ant_textbox_set_color(textbox, color, alpha)

Arguments

textbox Textbox to apply to
color BGR color value
alpha Alpha value 0-1

Returns: 0 if successful, -1 if not

Sets the color and alpha of the text inside the textbox. Will not affect other textbox graphical elements, like the selection color/strength.

ant_textbox_focus(textbox)

Arguments

textbox Textbox to focus

Returns: 0 if successful, -1 if not

Focuses the provided textbox. This will select it and show the virtual keyboard, if applicable.

ant_textbox_unfocus(textbox)

Arguments

textbox Textbox to unfocus

Returns: 0 if successful, -1 if not

Unfocus the provided textbox. This will deselect it and prevent further input from reaching it.

ant_textbox_is_focused(textbox)

Arguments

textbox Textbox to check

Returns: 0 if successful, -1 if not

Returns if the textbox is focused or not.

ant_textbox_has_submitted(textbox)

Arguments

textbox Textbox to apply to

Returns: True if the textbox hit submit, otherwise false

Returns true if the user has clicked the submit/enter key on the keyboard, since this function was ran last.

ant_textbox_set_enabled(textbox, enabled)

Arguments

textbox Textbox to apply to
enabled Controls if the textbox is enabled or not

Returns: 0 if successful, -1 if not

Configures if the textbox is visible and interactable. If enabled is set to false, the textbox will not be visible or pressable.

ant_textbox_set_focusable(textbox, focusable)

Arguments

textbox Textbox to apply to
focusable Controls if the textbox is focusable or not

Returns: 0 if successful, -1 if not

Set if the textbox is clickable or not. If it’s set to false the textbox will not be able to be pressed, but will still be visible.

ant_textbox_android_set_style(textbox, style)

Arguments

textbox Textbox to apply to
style Style-flags to apply to the textbox

Returns: 0 if successful, -1 if not

Applies the provided flags to the textbox on Android. This lets you mark a textbox as made for passwords, emails etc. All the constants are available here. To pass multile flags, use a bitwise or "|". This is only intended to be used if you require special functionality, for general use the normal style function is recommended.

ant_textbox_ios_set_style(textbox, type, capitalization, autocorrect)

Arguments

textbox Textbox to apply to
type Type of textbox this should be
capitalization Type of capitalization this textbox should use
autocorrect Type of autocorrect this textbox should use

Returns: 0 if successful, -1 if not

Applies the provided flags to the textbox on iOS. This lets you mark a textbox as made for emails, phone numbers etc. All the constants are available here. This is only intended to be used if you require special functionality, for general use the normal style function is recommended.

ant_textbox_ios_set_password(textbox, password)

Arguments

textbox Textbox to apply to
password If true, textbox is marked as password input

Returns: 0 if successful, -1 if not

Sets the box to be treated as a password box in iOS. This means the text will be converted into stars and you will not be able to copy text from it.