15-11-2020
Visit associated GitHub repository
Visit reference documentation page

Action menu items represent a menu item that does nothing more than run the callback when it is selected. There is no hard requirement for it to have a callback, but one without a callback would have no purpose.

Type information for ActionMenuItem

Creating an object from the designer

Choose to add a new menu item, and from the dialog choose Float item, once created the properties panel will look similar to:

image showing the action editor
Action Editor UI

For action items there are no special fields over and above the ones for all menu items.

Accessing action menu items from code

There are no specific functions for action items.

Creating an action menu item from the CLI

To create an action menu item from the CLI here is a template command (options in square brackets are optional):

tcmenu create-item --parent 0 --type action --name ActionName [--localonly --readonly --hide]

The structure of an action menu item in the EMF file is:

{
  "parentId": 0,
  "type": "actionMenu",
  "item": {
    "name": "ActionName",
    "variableName": "ActionName",
    "id": 3,
    "eepromAddress": 0,
    "readOnly": true,
    "localOnly": true,
    "visible": false,
    "staticDataInRAM": false
  }
}

Creating an action menu item manually

In nearly all cases it's better to create items using the designer. However, this is how you create an additional action item manually should it be required. You can drop the const and PROGMEM from the INFO structure if you choose to create in RAM (isInProgmem parameter set to false). Even for RAM items never change the ID after adding to menuMgr.

[const] ActionMenuInfo minfoActionItem [PROGMEM] = { "Action Item", myId, 0xFFFF,
                                         0, myCallback };
ActionMenuItem menuActionItem(&minfoActionItem, &nextMenuItem, [bool isInProgmem = true]);

Above we create an action item along with it's associated info structure. myId should be replaced with the unique ID for the item, myCallback will be called when the item is selected.

These may be of interest

Want to let us know about something?

We use cookies to analyse traffic and to personalise content. We also embed Twitter and Youtube on some pages, these companies have their own privacy policies.

See the privacy policy and terms of use of this site should you need more information or wish to adjust your settings.