ml::docs | Your First App Manifests Events Messaging Plugins Scenes Resources
See all tutorials →
Beginner 5 sections ~10 min C++17/20

Dialogs & Transient UI

Modals, toasts, context menus and info popovers — the controls that appear over your layout, ordered by how much they demand of the user.

Introduction

Choosing the Right One

Four controls handle the UI that appears over your layout rather than inside it. They differ in how much they demand of the user.

ControlInterrupts?Use for
ModalYes — blocks until answeredDecisions that must be made now
ToastNo — dismisses itselfConfirming something already happened
ContextMenuUntil chosen or dismissedActions attached to a place or object
InfoButtonNo — a popover on demandExplaining a control without cluttering it
Reach for the least interrupting option that works. A modal for something the user did not ask about is the most disruptive control in any interface — a toast usually says the same thing without stopping them.
2Passive

Toast

A toast reports something that already happened and then removes itself.

ml::Toast toast;
toast.setMessage("Quiz submitted");
toast.setAnchor(ml::Toast::Anchor::BOTTOM);
toast.show();

// With an action:
toast.setMessage("Note deleted");
toast.setActionLabel("Undo");
toast.onDismiss([&]{ restoreNote(); });
toast.show();
MethodEffect
setMessage(text)What happened.
setActionLabel(s)Optional action button. Empty hides it.
setAnchor(TOP|BOTTOM)Which edge it slides from.
show() / hide()Present and dismiss.
onDismiss(cb)Fires when it goes away.
Write toast text as a completed fact — "Quiz submitted", not "Submitting quiz…". By the time it is on screen the thing has happened, and present-tense wording reads as though something is still pending.
3Contextual

Context Menu

A context menu is a list of actions shown at a point — typically where the user right-clicked.

ml::ContextMenu menu;
menu.addItem("Rename",    [&]{ beginRename(); });
menu.addItem("Duplicate", [&]{ duplicate(); });
menu.addItem("Delete",    [&]{ confirmDelete(); });
menu.showAt(mousePosition);
MethodEffect
addItem(label, action)Append an entry.
clearItems()Empty it — rebuild per invocation when the actions vary.
showAt(pos)Present at a screen position.
hide()Dismiss.
setSearchable(bool)Add a filter field for long menus.
setMaxVisibleItems(n)Scroll beyond this many.
setFixedWidth(w)Pin the width instead of fitting content.
onClose(cb)Fires on dismissal, chosen or not.
For menus whose entries depend on what was clicked, call clearItems() and rebuild before each showAt. A stale menu offering actions that no longer apply is worse than no menu.
4Help

Info Button

An info button is a small circular ? that reveals a popover — help text that would otherwise crowd the control it explains.

ml::InfoButton help;
help.setText("Students see this name in their course list.");
help.setPopoverWidth(240.f);
help.setRightOf(courseNameField, 8.f);
MethodEffect
setText(help)Popover body.
setPopoverWidth(w)Wrap width.
setRadius(r)Size of the button itself.
open() / close() / toggle()Drive it programmatically.
Use it for genuinely optional detail. If a user must read the text to use the control correctly, it belongs in a visible label, not hidden behind a button.