ItemList

Defines

ITEM_STRING_LIST(...)
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.

inline String *getItems()

Returns a pointer to the array of items.

Returns:

A pointer to the array of items.

inline char *getValue()

Returns the value of the currently selected item.

Returns:

The value of the currently selected item.

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 or LEFT. 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 or MenuScreen

  • 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)

Private Members

fptruInt callback = NULL
String *items = NULL
const uint8_t itemCount
uint8_t itemIndex = 0