ItemCommand
-
class ItemCommand : public MenuItem
- #include <ItemCommand.h>
Represents a menu item that executes a command when selected.
The ItemCommand class inherits from MenuItem and allows for the execution of a callback function when the item is entered. This is useful for creating interactive menu items in an LCD menu system.
Note
The callback function should match the signature defined by the fptr type.
Public Functions
-
inline ItemCommand(const char *text, fptr callback)
Construct a new ItemCommand object.
- Parameters:
text – The text of the item.
callback – A reference to the callback function to be invoked when the item is entered.
Protected Functions
-
inline virtual bool process(LcdMenu *menu, const unsigned char command) override
Process a command decoded in 1 byte. It can be a printable character or a control command like
ENTER
orLEFT
. Return value is used to determine operation was successful or ignored. If the parent of item received that handle was ignored it can execute it’s own action on this command. Thus, the item always has priority in processing; if it is ignored, it is delegated to the parent element. Behaviour is very similar to Even Bubbling in JavaScript.- Parameters:
menu – the owner menu of the item, can be used to retrieve required object, such as
DisplayInterface
orMenuScreen
command – the character command, can be a printable character or a control command
- Returns:
true if command was successfully handled by item.
-
inline ItemCommand(const char *text, fptr callback)