Skip to content
ModernUI A DaneTrades developer library

Buttons

Buttons are used for actions.

For normal EA code, create buttons normally, assign .Id(...), and handle clicks in OnMuiEvent(...).

Basic button with event bus

Reference excerpt
enum PANEL_ACTION
  {
   PANEL_ACTION_SAVE,
   PANEL_ACTION_RESET
  };
UI build fragment
m_bSave=Mui::ButtonPrimary(parent,"Save");
m_bSave.Id(PANEL_ACTION_SAVE);

m_bReset=Mui::Button(parent,"Reset");
m_bReset.Id(PANEL_ACTION_RESET);
Reference excerpt
void CPanel::OnMuiEvent(MuiRoot &root,const MuiEventData &event)
  {
   if(event.EventId()==MUI_EVENT_CLICK && event.ControlId()==PANEL_ACTION_SAVE)
      Mui::ToastSuccess(root,"Saved");
  }

Main creation helpers

Helper Use it for
Mui::Button Standard action button
Mui::ButtonPrimary Primary action
Mui::ButtonGhost Lower-emphasis action
Mui::ButtonDanger Destructive or risky action
Mui::IconButton Icon-only action
Mui::ButtonIcon Icon plus text
Mui::ButtonRow Multiple independent action buttons
Mui::ButtonGroup Mutually exclusive choice buttons

Icon buttons

UI build fragment
MuiButtonAction *settings=Mui::IconButton(parent,MUI_ICON_SETTINGS);
settings.Id(PANEL_ACTION_OPEN_SETTINGS);

For icon plus text:

UI build fragment
MuiButtonAction *refresh=Mui::ButtonIcon(parent,MUI_ICON_REFRESH,"Refresh");
refresh.Id(PANEL_ACTION_REFRESH);

ButtonRow

Use ButtonRow for independent actions in one row.

UI build fragment
string actions[];
ArrayResize(actions,3);
actions[0]="Save";
actions[1]="Reset";
actions[2]="Close";

MuiButtonRow row=Mui::ButtonRow(parent,actions,0.0,0.0,true);

if(row.Button(0)!=NULL)
   row.Button(0).Id(PANEL_ACTION_SAVE);
if(row.Button(1)!=NULL)
   row.Button(1).Id(PANEL_ACTION_RESET);
if(row.Button(2)!=NULL)
   row.Button(2).Id(PANEL_ACTION_CLOSE);

Each button is independent. Selecting one does not affect the others.

ButtonGroup

Use ButtonGroup when one option should be selected.

UI build fragment
string modes[];
ArrayResize(modes,2);
modes[0]="Buy";
modes[1]="Sell";

MuiButtonGroup group=Mui::ButtonGroup(parent,modes,0,0.0,0.0,true);
group.Selected(1);

ButtonGroup manages selected styling internally.

Advanced handler path

Low-level MuiClickHandler classes and SetHandler(...) still exist for advanced reusable controls and compatibility. They are not the recommended first pattern for normal EA panels.

Use Event handlers only when an API specifically requires a handler object.

Related pages