davetcc / tcMenu

Menu library for Arduino, mbed and ESP with designer UI and remote control capabilities.
https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/
Apache License 2.0
275 stars 25 forks source link

Can "Navigate to Parent" focus the entrance item? #268

Closed luwenjin closed 1 year ago

luwenjin commented 1 year ago

for example, I have a menu structure like this:

A
B
- B1
C
- C1
D
- D1

When I navigated to B1, if I go to parent using the title, the focus will be on the first child of the parent menu (A).

I think it would be better if its focused on B, since it's the entrance of the submenu and is the last place before entering submenu. And if we have consecutive options to set (B, C, D), by focusing on the entrance menu, the navigation experience will be more fluent.

davetcc commented 1 year ago

On using the back menu, the navigator should put you back into the menu at whatever point you were before.

For example, if you clicked on B it would initially select the back menu item for B, which is the title. Then should you click on that back menu item, it will pop the navigation one level, and that should select B again.

I'm not sure I fully understand the problem to be honest, as it is now, unless something has gone wrong, navigating backward using the back menu item, the previously selected value will always become active. Normally that would be the submenu you clicked on. However, clicking on a submenu (such as B above) will result in the back menu becoming active, is this what the issue is for?

luwenjin commented 1 year ago

On using the back menu, the navigator should put you back into the menu at whatever point you were before.

Yep, that's what I was expecting.

However, I've tried simpleU8G2 example with 3.0.0 lib in these steps:

  1. click settings -> entered settings and the title is selected ✅
  2. click the title -> went back to root and selected "Toaster"(the first item) instead of "settings" 💔

It's the same as in my app.

davetcc commented 1 year ago

OK that is very odd, have you adjusted the number of navigation levels or something like that? How many levels deep is this, by default the maximum depth is I think 4, which would prevent menus with more than three submenu levels deep. You can easily change that by redefining MAX_MENU_DEPTH to be deeper. See https://www.thecoderscorner.com/products/arduino-libraries/

The default behaviour when clicking on the back menu item (title of sub-menu) is to go back to whatever was selected before, IE whatever was the active item when the navigate function was called.

luwenjin commented 1 year ago

It's the first level menu under root, I didn't go any deeper, and never touched MAX_MENU_DEPTH before. Can you reproduce this issue with example esp32/simpleU8G2 ?

davetcc commented 1 year ago

This is something that must have either gone wrong very close to the end of the dev cycle for 3.0 or not show on all environments, as it honestly did work during testing, but as of the release, agreed it is also broken for me. I'll debug and hope to patch the library soon. Thanks for reporting this.

davetcc commented 1 year ago

https://github.com/davetcc/tcMenuLib/issues/175

luwenjin commented 1 year ago

This bug also exists before I update to 3.0.0, you may check the code before 3.0.0