Skip to content
ModernUI A DaneTrades developer library

Drawer, Dialogs, and Menus

ModernUI overlays are used for secondary UI:

  • settings drawers
  • confirmation dialogs
  • modal alerts
  • context menus
  • temporary toasts
  • tooltips

Use overlays when the user needs a temporary panel, confirmation, or menu that should appear above the main UI.

Drawer

Create a drawer with Mui::Drawer.

UI build fragment
MuiDrawer *drawer=Mui::Drawer(300.0,true);

Add content to it as a container:

UI build fragment
MuiSection prefs=Mui::DrawerSection((MuiContainer*)drawer,"Preferences","Defaults");
Mui::LabeledCheckbox(prefs.body,"Confirm before close",true);

drawer.Open(g_ui);

DrawerSection does not create or open the drawer. It only creates a tighter section inside an existing drawer/container.

Modal alert

Use a modal alert for simple blocking information.

UI build fragment
Mui::ModalAlert(g_ui,"Saved","Settings have been saved.");

Confirmation dialog

Use confirmation for actions that require a yes/no decision.

Handler excerpt
class ConfirmCloseHandler : public MuiConfirmHandler
{
public:
  virtual void OnConfirm(MuiRoot &root,const bool ok)
  {
    if(ok)
      Mui::ToastSuccess(root,"Confirmed");
  }
};
UI build fragment
Mui::Confirm(
  g_ui,
  "Confirm action",
  "Do you want to continue?",
  new ConfirmCloseHandler()
);

Confirm handlers are callbacks. Follow the exact ownership pattern in the current dialog API and examples when using them in production code.

Context menu

Use a context menu for short menu actions at a chart coordinate.

UI build fragment
string items[];
ArrayResize(items,3);
items[0]="Refresh";
items[1]="Export";
items[2]="Reset";

Mui::ContextMenuAt(g_ui,120.0,80.0,items,new MenuActionHandler());

Context menus use MuiMenuItemHandler.

Toasts

Toasts are temporary overlays for lightweight feedback.

UI build fragment
Mui::ToastSuccess(g_ui,"Done");

Use dialogs for important confirmations. Use toasts for short feedback.

Overlay behaviour

Overlays are part of the ModernUI input and paint system.

This means:

  • modal UI should receive input before the underlying panel
  • drawers and dialogs paint above normal controls
  • click-outside and backdrop behaviour is handled by the overlay system where supported
  • chart events still need to be forwarded to g_ui.OnChartEvent(...)

Choosing the right overlay

Need Use
Side settings panel Drawer
Simple blocking message ModalAlert
User must approve/cancel Confirm
Short list of actions Context menu
Temporary success/warning feedback Toast
Small hover hint Tooltip

Common mistakes

Using toasts for confirmation

A toast disappears and does not collect a decision. Use Confirm.

Creating drawers without opening them

Create the drawer, add content, then call Open(g_ui).

Forgetting overlay input still depends on chart events

If chart events are not forwarded, overlays cannot route mouse and keyboard input correctly.

Related pages