Skip to content
ModernUI A DaneTrades developer library

Custom Intent Events

Custom intent events are optional high-level callbacks.

They sit beside the normal input routing system. A control does not need an intent handler to keep working.

Use them when you want to react to user-level actions such as:

  • table cell clicked
  • row selected
  • list item double clicked
  • tab changed by the user
  • combo option picked
  • dialog result chosen
  • drawer closed by the user

Include path

Reference excerpt
#include <ModernUI\ModernUI.mqh>

ModernUI.mqh includes the custom intent event layer.

Firing rules

Custom intent callbacks follow these rules:

  • user-driven paths invoke them
  • programmatic setters usually do not invoke them
  • callbacks run after internal state changes
  • preview callbacks can be high frequency

That means if a user clicks a table cell, the callback can read the new state immediately.

If your code calls Selected(...) directly, the custom intent may not fire.

Covered controls

Control Intent setters
MuiTableView SetCellClickedHandler, SetRowClickedHandler, SetCellDoubleClickedHandler, SetHeaderClickedHandler, SetSelectionChangedHandler
MuiListView SetItemClickedHandler, SetItemDoubleClickedHandler, SetSelectionChangedHandler
MuiTreeView SetNodeClickedHandler, SetNodeDoubleClickedHandler, SetSelectionChangedHandler, SetExpandedChangedHandler
MuiTabs SetTabChangedHandler
MuiAccordion SetExpandedChangedHandler
MuiComboBoxHost SetSelectionChangedHandler
MuiDropdown SetSelectionChangedHandler
MuiDatePicker SetDateChangedHandler
MuiColorPicker SetColorCommittedHandler, SetColorPreviewChangedHandler
MuiDialog SetResultHandler
MuiDrawer SetStateChangedHandler

Ownership summary

Most custom intent handlers are non-owned.

Area Ownership
List/table/tree intent handlers Not owned
MuiTabs::SetTabChangedHandler Not owned
MuiAccordion::SetExpandedChangedHandler Not owned
MuiComboBoxHost::SetSelectionChangedHandler Not owned
MuiDropdown::SetSelectionChangedHandler Not owned
MuiDatePicker::SetDateChangedHandler Not owned
MuiColorPicker committed/preview handlers Not owned
MuiDialog::SetResultHandler Not owned
MuiDrawer::SetStateChangedHandler Not owned

Some older/general control handlers are owned, such as combo SetHandler(...), dropdown menu handler paths, tab owned handler paths, and accordion per-item toggle handlers. Do not assume all handler APIs follow the same ownership model.

Table cell click example

Handler class
class LogCellIntent : public MuiTableCellClickedEventHandler
{
public:
  virtual void OnTableCellClicked(MuiTableView *table,const int row,const int col,const string value)
  {
    Print("Cell ",row,",",col," = ",value);

    if(table!=NULL)
      table.Refresh();
  }
};

static LogCellIntent s_cellIntent;
UI build fragment
if(table!=NULL)
  table.SetCellClickedHandler(&s_cellIntent);

Because this handler is non-owned, a static/global instance is a good safe pattern.

What not to duplicate

Use existing abstractions for:

  • menu items: MuiMenuItemHandler::HandleMenuItem
  • generic button clicks: MuiClickHandler on MuiButtonAction

Custom intents are for higher-level control-specific user intent, not every possible event.

Common mistakes

Expecting programmatic selection to fire custom intent

Custom intents are mainly user-driven. If your code changes selection and also needs side effects, call your own application method directly.

Passing a temporary handler to a non-owned callback

Non-owned callbacks must outlive the control.

Doing heavy work in preview handlers

Colour preview changes may be high frequency. Keep preview handlers lightweight.

Related pages