Skip to content
ModernUI A DaneTrades developer library

ButtonRow and ButtonGroup

ButtonRow creates independent action buttons.

ButtonGroup creates mutually exclusive choice buttons.

For normal EA panels, assign .Id(...) to buttons and route clicks through OnMuiEvent(...).

ButtonRow

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);

Handle the clicks centrally:

Reference excerpt
if(event.EventId()==MUI_EVENT_CLICK)
  {
   if(event.ControlId()==PANEL_ACTION_SAVE)
      OnSave(root);
   else if(event.ControlId()==PANEL_ACTION_RESET)
      OnReset(root);
   else if(event.ControlId()==PANEL_ACTION_CLOSE)
      OnClose(root);
  }

ButtonGroup

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

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

Use ButtonGroup when the UI needs one selected option.

Advanced handlers

Low-level button handlers still exist for advanced/custom control work, but they are not the recommended first pattern for EA panels.

Use the event bus unless a specific API requires a handler object.

Related pages