Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two more features needed #123

Open
MartinNohr opened this issue Apr 18, 2021 · 1 comment
Open

Two more features needed #123

MartinNohr opened this issue Apr 18, 2021 · 1 comment

Comments

@MartinNohr
Copy link

There should be a call to return the number of items in the menu.
A call is also useful that will return the name of an item using the index.
I am keeping a list of files in the menu and these functions make it easier to work with so I don't need to keep a separate array of filenames.
I have added them to my copy of the code, but you might consider adding them to the main code.
Otherwise I'm finding M5ez quite useful. Thanks for the good work.

@MartinNohr
Copy link
Author

Actually, a better suggestion to keep your code more general and just allow subclassing would be to make the following change.
protected:
int16_t _selected;
struct MenuItem_t {
String nameAndCaption;
const char* image;
fs::FS* fs;
String path;
void (*simpleFunction)();
bool (advancedFunction)(ezMenu callingMenu);
void (drawFunction)(ezMenu callingMenu, int16_t x, int16_t y, int16_t w, int16_t h);
};
std::vector<MenuItem_t> _items;
void _fixOffset();

Making those variables protected instead of private allows me to derive a class with the features I need and still use your base code without any modifications. Then I can get any updates without having to keep my own modified version of your code.

Thanks for considering this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant