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

textboxTextbox to remove

Returns: 0 if successful, -1 if not

Removes the provided textbox

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

Arguments

textboxTextbox to apply to
xPosition y in pixels
yHeight in pixels
widthWidth in pixels
heightHeight 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

textboxTextbox to apply to
sizeSize 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

textboxTextbox to apply to
fontName 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 provideActual font
sans-serif-thinRoboto Thin
sans-serif-lightRoboto Light
sans-serifRoboto Regular
sans-serif-mediumRoboto Medium
sans-serif-blackRoboto Black
sans-serif-condensed-lightRoboto Condensed Light
sans-serif-condensedRoboto Condensed Regular
sans-serif-condensed-mediumRoboto Condensed Medium
serifNoto Serif
monospaceDroid Sans Mono
serif-monospaceCutiveMono
cursiveDancing Script
sans-serif-smallcapsCarroisGothic SC

ant_textbox_ios_set_font(textbox, font)

Arguments

textboxTextbox to apply to
fontName 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

textboxTextbox to apply to
typeType of textbox this should be
capitalizationType of capitalization this textbox should use
autocorrectType 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 typeDescription
ant_style_type_defaultShows a default keyboard
ant_style_type_asciiShows a keyboard with ascii only
ant_style_type_urlShows a keyboard for url input
ant_style_type_emailShows a keyboard for email input
ant_style_type_passwordHides the entered text and does not allow copying
ant_style_type_numbersShows a numberpad

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

Capitalization typeDescription
ant_style_capitalize_noneNothing is capitalized
ant_style_capitalize_wordsWords are capitalized
ant_style_capitalize_sentencesSentences are capitalized
ant_style_capitalize_allAll text is capitalized

This constant determines if autocorrect should be enabled or not

Autocorrection typeDescription
ant_style_autocorrect_offAutocorrect is disabled
ant_style_autocorrect_onAutocorrect is enabled

ant_textbox_set_text(textbox, text)

Arguments

textboxTextbox to apply to
textText 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

textboxTextbox 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

textboxTextbox to apply to
colorBGR color value
alphaAlpha 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

textboxTextbox 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

textboxTextbox 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

textboxTextbox to check

Returns: 0 if successful, -1 if not

Returns if the textbox is focused or not.

ant_textbox_has_submitted(textbox)

Arguments

textboxTextbox 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

textboxTextbox to apply to
enabledControls 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

textboxTextbox to apply to
focusableControls 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

textboxTextbox to apply to
styleStyle-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

textboxTextbox to apply to
typeType of textbox this should be
capitalizationType of capitalization this textbox should use
autocorrectType 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

textboxTextbox to apply to
passwordIf 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.