-
Notifications
You must be signed in to change notification settings - Fork 3
EmuDialog
A Dialog is a special UI element which does not need to be added to any container and can be dragged around the screen independently. They are commonly used for pop-up windows which may contain notices, yes / no questions or other kinds of UI.
Dialogs are containers, and you may add elements to them the same way you would with an EmuCore or an EmuTab.
Unlike other containers, Dialogs do not need to be (and should not) be added to a container manually. Instead, calling EmuOverlay.Render() will render all existing dialogs at once (if any exist). In most cases, this should be included at the end of the Draw / Draw GUI event so that dialogs will be rendered on top of everything else.
A dialog box showing the credits for Emu UI. You may include any elements in a dialog box, including tabs, render surfaces or other EmuCore containers.
Inheritance: EmuCore / EmuCallback
EmuDialog(width, height, title)
Parameter | Type | Description |
---|---|---|
w | real | The width of the dialog |
h | real | The height of the dialog |
title | string | The text shown in the title bar |
Dialog windows are placed on the screen automatically when spawned.
Returns: N/A
Parameter | Type | Description |
---|---|---|
callback | function | The function invoked when the Close button is clicked or the Escape key is pressed |
Under most circumstances you will not need to override the behavior of the Close button on a dialog window, but in cases where you do (e.g. asking the user to confirm changes) you can define a callback.
By default, the close button callback simply calls the dialog's Close()
method.
Returns: N/A
Close the dialog window. If there are any dialog windows on top of it, they will be closed automatically and you will not need to call this method for each of them.
var dialog = new EmuDialog(640, 320, "Hey, listen!");
dialog.AddContent([
new EmuText(32, 32, 576, 32, "These are words that you can read"),
new EmuCheckbox(32, 80, 320, 32, "Toggle option", false, function() { }),
new EmuButton(dialog.width / 2 - 128 / 2, dialog.height - 32 - 32 / 2, 128, 32, "Close", emu_dialog_close_auto),
]);
This will create an EmuDialog window and populate it with some text, a checkbox, and a Close button. Note that the dialog does not need to be added to a container.
This will allow an element inside a Dialog window to close its parent dialog. This can be useful for buttons which say "Close" or "Confirm" or serve a similar purpose.