-
Notifications
You must be signed in to change notification settings - Fork 87
Dialogs and prompts
Some built-in views are made to be used as dialogs or prompts. They have a simplified API to open them and get the choice or value selected by the user once they are closed - you don't need to push and pop them manually on and from the stack.
Dialogs are simple pop-ups with a message and optionally some buttons. Dialogs can be made cancelable - pressing B on a cancelable dialog will close it. Dialogs without any buttons cannot be cancelable.
To open a dialog, first create an instance of the Dialog
class. Call the corresponding methods to add your buttons, set it cancelable (or not) and finally call open()
to open it. If the user clicks a button, the dialog will be closed and the corresponding callback will be called.
Dropdowns allow you to prompt the user for a value, from a predetermined list.
You can open a dropdown using the static Dropdown::open()
method. Give it a title, a list of values and a callback. You can also specify the "currently selected value" which will have a check mark icon displayed next to it.
When the user selects a value, it will trigger the callback with the selected value index. If the user closes the dropdown without selecting anything, the callback will be triggered with -1
as selected value index.
Popup frames are in the style of the HOS games "details" dialog. They take a title, an icon and a content view for their body.
You can open them with the static PopupFrame::open()
method.
That one allows you to display a "fatal" error message where the only choice for the user is to quit the application. You can open a crash frame by calling Application::crash()
.
Some have tried to plug the C++ exceptions handlers to a crash frame... while it's risky because you cannot guarantee that the borealis state is sane after an exception, it makes for a cool way to report an unhandled exception crash in your app.