Skip to content
ModernUI A DaneTrades developer library

Text Inputs

ModernUI text inputs use native OBJ_EDIT hosts where real text editing is needed.

Use them when the user must type, select, copy, paste, or edit text.

Main helpers

Helper Use it for
Mui::TextBox Single-line text input
Mui::TextArea Multi-line or larger text input
Mui::LabeledTextBox Label plus text box
Mui::LabeledTextArea Label plus text area

TextBox

UI build fragment
MuiTextBoxHost *name=Mui::TextBox(parent,"Default name",260.0,0.0);

Read and write text:

UI build fragment
if(name!=NULL)
{
  string value=name.Text();
  name.Text("Updated name");
}

TextArea

UI build fragment
MuiTextAreaHost *notes=Mui::TextArea(parent,"First line",420.0,0.0,false);

Use a text area for longer input. The default height follows the theme text area minimum unless you pass a positive height.

Labelled text inputs

For most forms, prefer the labelled wrappers.

UI build fragment
MuiLabeledTextBox profile=Mui::LabeledTextBox(
  section.body,
  "Profile name",
  "Default",
  0.0,
  0.0,
  "Used by your EA settings."
);

MuiLabeledTextArea notes=Mui::LabeledTextArea(
  section.body,
  "Notes",
  "",
  0.0,
  0.0,
  "Optional."
);

Native host behaviour

Text boxes and text areas are different from pure canvas controls because they use native chart objects for editing.

That gives the user real text editing behaviour, but it also means:

  • the host must be synced with chart position and clipping
  • native host cleanup matters
  • g_ui.Shutdown() should be called in OnDeinit()
  • text hosts should not be moved or recreated unnecessarily

Required lifecycle

Reference excerpt
void OnDeinit(const int reason)
{
  g_ui.Shutdown();
}

Call Shutdown() before tearing down chart objects so native hosts can remove their OBJ_EDIT objects cleanly.

Sizing

Argument Behaviour
TextBox width 0 Use default text input width
TextBox height 0 Use theme input height
TextArea height 0 Use theme text area minimum height
positive dimensions Use the explicit size where supported

When not to use text inputs

Avoid text inputs for values that should be constrained. Use:

  • Mui::SpinEdit for numbers
  • Mui::ComboBox for known options
  • Mui::Checkbox or Mui::Toggle for boolean state
  • Mui::Slider for approximate range values

Common mistakes

Forgetting native host cleanup

Always keep g_ui.Shutdown() in OnDeinit().

Using TextBox for numeric settings

Use SpinEdit when the value has min, max, step, and digits.

Rebuilding text inputs too often

Text hosts are heavier than simple labels or buttons. Prefer updating the existing control instead of destroying/recreating it repeatedly.

Related pages