Setter Naming
ModernUI exposes short, consistent setter names for common updates.
Use these names in new examples and docs.
Older names remain supported where they already existed.
Preferred names
| Area | Preferred names |
|---|---|
| Text/value/state | Text, Value, Checked, Selected, SetHandler |
| Sizing/shape | Size, SizePt, Pad, Radius |
| Colours | BgColor, BorderColor, TextColor, AccentColor |
| Row/header metrics | RowHeight, HeaderHeight, ItemHeight |
| Refresh/layout | Refresh, Relayout, RefreshAll, RefreshArea |
| Control-specific polish | StepperFilled, ThumbSize, knob shape setters where available |
Refresh and layout — friendly aliases
ModernUI also exposes short, friendly aliases for refresh/layout calls. Prefer these in new code; the older internal names below still compile.
| Friendly public method | Existing/internal method | Use it when |
|---|---|---|
Refresh() (on control) |
InvalidateSelf() |
A control changed visually |
Relayout() (on control) |
RequestLayoutSelf() |
Size, spacing, children or layout changed |
g_ui.Refresh() / g_ui.RefreshAll() |
g_ui.Invalidate() |
The whole UI should redraw |
g_ui.RefreshArea(r) |
g_ui.InvalidateRect(r) |
A known area changed |
g_ui.Relayout() / g_ui.RelayoutAll() |
g_ui.RequestLayout() |
Structural changes across the panel |
statusLabel.Refresh();
panel.Relayout();
g_ui.RefreshAll();
MuiRect area; area.x=20; area.y=20; area.w=120; area.h=24;
g_ui.RefreshArea(area);
Examples
MuiButtonAction *button=Mui::Button(parent,"Save",NULL,160.0,0.0);
button.Text("Save settings");
button.Pad(14.0,8.0);
button.Radius(10.0);
button.SizePt(12);
MuiSlider *slider=Mui::HorizontalSlider(parent,0.0,1.0,0.35,NULL,220.0,0.0);
slider.Value(0.50);
slider.AccentColor(0xFF2563EB);
MuiTabs *tabs=Mui::Tabs(parent,0.0,0.0);
tabs.Selected(g_ui,2);
tabs.HeaderHeight(32.0);
MuiLabeledSpinEdit lots=Mui::LabeledSpinEdit(section.body,"Lots",0.01,50.0,0.01,0.10);
if(lots.control!=NULL)
lots.control.StepperFilled(true); // default modern filled stepper
MuiSlider *reward=Mui::HorizontalSlider(parent,0.5,5.0,2.0,NULL,220.0,0.0);
reward.UseRectangleKnob();
reward.ThumbSize(16.0);
Creation helpers vs setters
Creation helpers assemble controls.
MuiLabeledSpinEdit risk=Mui::LabeledSpinEdit(section.body,"Risk %",0.1,10.0,0.1,1.0);
Setters customise controls after they exist.
if(risk.control!=NULL)
{
risk.control.Value(2.0);
risk.control.AccentColor(0xFF2563EB);
}
This is the normal ModernUI pattern:
create quickly
then customise the returned control handles
Compatibility names
Older names remain valid where supported.
| Older/common name | Preferred short name |
|---|---|
Padding(px,py) |
Pad(px,py) |
CornerRadius(r) |
Radius(r) |
FontSize(pt) |
SizePt(pt) |
SelectedRow(index) |
Selected(index) where alias exists |
Do not rewrite working code just to change old names, but use the preferred names in new docs and examples.
Why setters are not generally chainable
ModernUI setters are usually void.
Do this:
button.Text("Save");
button.Pad(14.0,8.0);
button.Radius(10.0);
Do not assume this will work:
button.Text("Save").Pad(14.0,8.0).Radius(10.0);
MQL5 method chaining is not reliable enough to make it the default style for this library.
Generic names vs specialised names
Use generic names when the concept is shared:
TextValuePadRadiusAccentColor
Keep specialised names where the role is specific:
LineColorAxisColorGridColorHeaderBgRowHeightBorderFocusNativeFontAdjust
The goal is a shared vocabulary, not forcing every control into the same method names.
Layout vs paint
Some setters change only paint. Others change layout.
| Setter type | Typical effect |
|---|---|
Text |
paint, sometimes layout |
Value |
paint, sometimes layout |
Pad |
layout and paint |
Radius |
paint |
SizePt |
layout and paint |
BgColor / BorderColor / TextColor |
paint |
RowHeight |
layout and paint |
Avoid layout-heavy setters inside high-frequency handlers unless necessary.
Common mistakes
Expecting every control to have every setter
Only use setters that apply to the specific control.
Styling through giant creation signatures
Creation helpers are for structure. Use setters for detailed visual changes.
Assuming programmatic setters always fire user handlers
Programmatic setters generally should not call user handlers unless that behaviour is explicitly documented for that control.