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

[NEW-FEATURE] - Add items during runtime #291

Open
almofada1 opened this issue Jan 5, 2025 · 4 comments
Open

[NEW-FEATURE] - Add items during runtime #291

almofada1 opened this issue Jan 5, 2025 · 4 comments
Labels
feature-request Add new feature to the library

Comments

@almofada1
Copy link

Is your feature request related to a problem?

While developing one of my projects, I realised I would need to display the names of devices that would be discovered during runtime. So various submenus would be created as soon a device was detected and inside it there would be x items.

Describe the solution you'd like?

The only solution I can think of is to use constructors to create either menus, submenus or items. By doing this, a dynamic menu could be created and there would be more room for development. Adding a function to remove dynamic items would be appreciated as well.

Describe alternatives you've considered

Tried using constructors but no luck.

Additional context

I might not know if this feature already exists but if it doesn't I'd really appreciate it as it would be very helpful to the project.

@almofada1 almofada1 added the feature-request Add new feature to the library label Jan 5, 2025
@forntoh
Copy link
Owner

forntoh commented Jan 5, 2025

You can always create a screen dynamically like this

MenuItem* items[] = { 
    ITEM_BASIC("Test1"),
    ITEM_BASIC("Test2"),
    nullptr
};
MenuScreen* screen = new MenuScreen(items)

And display the screen with

menu.setScreen(mainScreen);

don't forget to cleanup memory if it's no longer needed

delete[] items;
delete screen;

In the future, I'll add a setScreen method to ITEM_SUBMENU so you can update the screen for a sub-menu on runtime.

@almofada1
Copy link
Author

When would that be?

@forntoh
Copy link
Owner

forntoh commented Jan 6, 2025

I’m not sure at the moment, it really depends on when I have some free time. When it comes to developing this library, nothing is ever set in stone. I usually check out a few issues or discussions whenever I get the chance and work on possible solutions. I maintain it simply because I enjoy it.

@almofada1
Copy link
Author

Ok, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Add new feature to the library
Projects
None yet
Development

No branches or pull requests

2 participants