I want a single line of code which shows a popup dialog with the words "Hello World!" and an "Ok" button. (I want something simple for now, I know how to make something more complicated but that would be stupid at this point in development).

  • \$\begingroup\$ Hi Strategy Thinker, have you searched for any Godot tutorials? Last time I searched online, I found more than enough sites with helpful content. \$\endgroup\$ – TomTsagk Dec 13 '19 at 11:54
  • \$\begingroup\$ @TomTsagk Before posting this question I searched for "godot message box", "godot dialogue tutorial", "godot message to user", "godot popup message to user", "godot pupup dialog example", "godot display message on screen", "godot messagebox show", "godot message box show" \$\endgroup\$ – Strategy Thinker Dec 14 '19 at 23:05

You can use the OS / platform's alert system:

OS.alert('This is your message', 'Message Title')

You can use WindowDialog or subclass on any node like this:

func alert(text: String, title: String='Message') -> void:
    var dialog = AcceptDialog.new()
    dialog.dialog_text = text
    dialog.window_title = title
    dialog.connect('modal_closed', dialog, 'queue_free')

You can do the above, but globally:

func alert(text: String, title: String='Message') -> void:
    # ... code from above, but instead of `add_child(dialog)` do
    var scene_tree = Engine.get_main_loop()
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.