ItemList
-
class ItemList : public MenuItem
- #include <ItemList.h>
A class representing a list of items in a menu.
The ItemList class extends the MenuItem class and provides functionality for displaying and interacting with a list of items in a menu. It supports navigation through the items and executing a callback function when an item is selected.
Public Functions
-
inline ItemList(const char *key, String *items, const uint8_t itemCount, fptruInt callback)
Constructs a new ItemList object.
- Parameters:
key – The key of the menu item.
items – The array of items to display.
itemCount – The number of items in the array.
callback – A pointer to the callback function to execute when this menu item is selected.
-
inline uint8_t getItemIndex()
Returns the index of the currently selected item.
- Returns:
The index of the currently selected item.
-
inline bool setItemIndex(uint8_t itemIndex)
Changes the index of the current item.
Note
You need to call
LcdMenu::refresh
after this method to see the changes.- Returns:
true if the index was changed successfully, false otherwise.
-
inline fptruInt getCallbackInt()
Get the callback bound to the current item.
- Returns:
The the callback bound to the current item.
-
inline uint8_t getItemCount()
Returns the total number of items in the list.
- Returns:
The total number of items in the list.
Protected Functions
-
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.
-
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 selectPrevious(MenuRenderer *renderer)
-
inline void selectNext(MenuRenderer *renderer)
-
inline ItemList(const char *key, String *items, const uint8_t itemCount, fptruInt callback)