[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 

Set / Get value by id RSS feed
Forum Index » tcMenu Arduinio library
Author Message
JADaveIII


Joined: Jan 13, 2021
Messages: 2
Offline
The ability to use , for example:

void CALLBACK_FUNCTION editRoomsDef (int id)


and then get the value when the item is being edited will not work for me as the menu structure will change as the program is developed. And thus the callback name will change. Is there any plan to add a field for a users set a callback name vs the implicit menu text?

I would like to use the id of a menu item to set it's value upon program startup and get it's value after editing.

I cannot find any reference to use "id" to get / set a value in my main program. How is this done?

Unfortunately, if there are any Arduino Example programs, I can't find them.

Thanks!
davetcc


Joined: Jan 19, 2019
Messages: 243
Offline
I'm not 100% sure that I follow here, but I think your main question is that you want to get the value by ID. I found it in the reference documentation linked from the tcMenu project main page.

https://www.thecoderscorner.com/ref-docs/tcmenu/html/_menu_iterator_8h.html

MenuItem * 	getMenuItemById (int id)


You'd then need to cast the menu item to the right type, see the guide on menu types for help with each possibility: https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/menu-item-types/

Quick question, would you like the ability to override the variable name used for the menu? I've had one request for that before, and I'm beginning to think it could be very useful in larger projects.

JADaveIII


Joined: Jan 13, 2021
Messages: 2
Offline
Yes, I would like the ability to override the variable name used for the menu.

I would like to override the ID also. If the ID currently is used for a linked list, the so be it but add a user ID that can be changed after the initial menu item definition.

Can you be more explicit about using "MenuItem * getMenuItemById (int id)" ?

By trial and error I coded this


MenuItem * xxx;
xxx = getMenuItemById (20); // ID 20 is a plain text data entry in a multi-item menu

And it compiled.

But what now to get the actual data and/or set it? I can't even figure out (or find in the documentation) the text object data name in the what ever the type of object it's in.

If there was just one complete example I could figure it out.

Sorry for the rant. I'm sure the documentation is instantly understandable by people that use Class and Object and other C++ / OOPS constructs every day.
But I don't even though I have used plain C and a dozens of other languages for 50 years.



davetcc


Joined: Jan 19, 2019
Messages: 243
Offline
Sorry for the rant. I'm sure the documentation is instantly understandable by people that use Class and Object and other C++ / OOPS constructs every day.
But I don't even though I have used plain C and a dozens of other languages for 50 years.


tcMenu can't solve everyone's problems, and we don't pretend that it does. Using the library assumes a full understanding of OO, we cannot provide that here.

As per the last message, the return value will be a pointer to a type extending from MenuItem. In the menu types documentation (linked in the last reply) each type is documented fully, theres is also full reference documentation linked from the tcMenu project page, this shows the hierarchy of menu items.

As an example, if you wanted to deal with an AnalogMenuItem you would do:

AnalogMenuItem* analogItem = reinterpret_cast<AnalogMenuItem*>(getMenuItemById(myId));


For text menu item, that would be TextMenuItem instead of AnalogMenuitem.

MenuItem types:

https://www.thecoderscorner.com/ref-docs/tcmenu/html/class_menu_item.html
https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/menu-item-types/editabletext-menu-item/
https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/menu-item-types/

Making the IDs changeable after initialization will not be possible as they are treated as immutable data by the API, rendering classes and also remote interfaces. However, you can add extra items at runtime yourself. Many examples add an extra item to an existing menu.

 
Forum Index » tcMenu Arduinio library
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer