ItemToggle
-
class ItemToggle : public MenuItem
- #include <ItemToggle.h>
Item that allows user to toggle between ON/OFF states.
┌────────────────────────────┐ │ > T E X T : O F F │ └────────────────────────────┘
Additionally to
text
this item has ON/OFFenabled
state.Public Functions
-
inline ItemToggle(const char *key, fptrBool callback)
Create an ItemToggle object with default values as
ON
andOFF
.- Parameters:
key – key of the item
callback – reference to callback function
-
inline ItemToggle(const char *text, boolean enabled, fptrBool callback)
Construct a new Item Toggle object with an initial state and default ON/OFF texts.
- Parameters:
text –
enabled –
callback –
-
inline ItemToggle(const char *text, const char *textOn, const char *textOff, fptrBool callback)
Construct a new Item Toggle object.
- Parameters:
text – the text of the item
textOn – display text when ON
textOff – display text when OFF
callback – reference to callback function
-
inline fptrBool getCallbackInt()
Get the integer callback function of this item.
- Returns:
the integer callback function
-
inline void setIsOn(boolean isOn)
Set the current state of this toggle item.
Note
You need to call
LcdMenu::refresh
after this method to see the changes.- Parameters:
isOn – the new state
-
inline virtual void draw(MenuRenderer *renderer) override
Draw this menu item on specified display on current row.
- Parameters:
renderer – The renderer to use for drawing.
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 void toggle(MenuRenderer *renderer)
-
inline ItemToggle(const char *key, fptrBool callback)