Skip to reading
Buttons, Labels & Text Boxes

Offer a Submit button as another route

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView illustrations

A visible Submit button is useful when you also want a tap/click route. Create a GDScript record called submit_command, then call it from that button's Click event.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var command: String = str(GetGUIElementProperty(
        "workshop_hud", "hud_parser", "text", ""
    )).strip_edges()
    if command.is_empty():
        return false
    SetGUIElementProperty(
        "workshop_hud", "hud_parser", "value", ""
    )
    await Runtime.run_text_parser_command(command)
    return true

This native GDScript helper reads the field before clearing it and passes that saved sentence to the runtime parser. It does not need a new parser rule for the Submit button itself.

Figure 29. The status response in the fresh preview uses the starting visitor and score.

Figure 30. The HUD has both the Enter field and a separate Submit button. The field is empty again after submission.

The button helper does not add an extra focus-restoration routine after it rebuilds the field. The player can click the field again. Use the built-in Enter route when its return-focus behavior is the one you want for repeated typing.

Page 38 of 46Permalink
Go to page