Native Input Hosts
Most ModernUI controls are painted on a CCanvas-backed surface.
Text editing is different.
For real text editing, ModernUI uses native MT5 chart objects such as OBJ_EDIT behind host controls.
This gives users normal text editing behaviour, but it also creates extra lifecycle and positioning rules.
Host controls
Native host behaviour is relevant to controls such as:
MuiTextBoxHostMuiTextAreaHostMuiSpinEditHostMuiComboBoxHost
Some of these combine canvas-painted UI with native edit/input chrome.
Why hosts exist
Canvas-only text input is limited.
Native hosts help with:
- typing
- editing
- caret behaviour
- selection
- copy/paste
- native keyboard input
Sync behaviour
Native hosts sync from the root during paint/layout paths.
Important sync concerns:
- chart position
- control geometry
- clipping
- visibility
- focus
- chart object size
- chart object visibility
The host should not be moved or recreated on every mouse move.
Cleanup
Always call g_ui.Shutdown() in OnDeinit().
void OnDeinit(const int reason)
{
g_ui.Shutdown();
}
This lets hosts remove their native chart objects cleanly.
TextBox example
MuiTextBoxHost *name=Mui::TextBox(parent,"Default name",260.0,0.0);
For form layouts:
MuiLabeledTextBox profile=Mui::LabeledTextBox(
section.body,
"Profile name",
"Default",
0.0,
0.0,
"Native text editing."
);
TextArea example
MuiTextAreaHost *notes=Mui::TextArea(parent,"",420.0,0.0,false);
For form layouts:
MuiLabeledTextArea notes=Mui::LabeledTextArea(
section.body,
"Notes",
"",
0.0,
0.0,
"Optional."
);
MT5 limitations
Native chart objects are not the same as normal desktop UI controls.
Expect constraints around:
- clipping
- z-order
- chart redraw timing
- exact positioning during scroll/resize
- styling limitations
- behaviour differences across terminal builds
ModernUI hides as much of this as practical, but it cannot make MT5 behave exactly like a native desktop UI toolkit.
Common mistakes
Forgetting shutdown
If native chart objects remain after removing an EA, check g_ui.Shutdown().
Recreating native inputs unnecessarily
Update existing controls when possible.
Expecting full CSS-like styling
Native host objects have MT5 limitations. Use ModernUI theming and setters where supported.
Putting too many text inputs in tiny panels
Native input hosts are heavier than labels/buttons. Keep compact panels focused.