Register / Login  |  Desktop view  |  Jump to bottom of page

tcMenu Arduinio library » How can I catch menuItem selection change events?

Author: Frank
14/09/2020 19:34:19
Good evening Dave,

great library family, love it very much!

Is there a simple way to catch more user activity in the menu selection process?
I.e. callbacks for "MenuItem changed" or "MenuItem opend for Edit" etc ....

Use case: depending on the selected menu you might want to switch on/off an led ... just an example


Thank you for your help, much appreciated

Author: davetcc
15/09/2020 07:06:50
Hi there,

Thanks for using the library, and the compliment.

There's a couple of callbacks that you can use to determine when things have changed. But at the moment we don't have one for edit started. However, I think that would be easy to add, please add an issue in tcMenuLib https://github.com/davetcc/tcMenuLib and I'll try and do it in a patch release, as it shouldn't be much work.

What you can do now:

Every menu item supports a callback, you can set these in the designer, and the function gets called with each an every change, for an integer edit this could be a lot of times.

You can in addition to this, add a commit handler in menuMgr, this gets called once when editing stops:

void setItemCommittedHook([](int id) {
  // do your commit code here.
});



I guess we could do something along the lines of:

void setItemEditStarting([](int id) {
  // do your edit start code here.
});






Register / Login  |  Desktop view  |  Jump to top of page