Jomelo / LCDMenuLib2

Create a tree menu. Use it with different lcd types / console output / ssh console.
MIT License
249 stars 47 forks source link

MENU_getLayer on Root menu #22

Closed mavrickJ closed 6 years ago

mavrickJ commented 6 years ago

Hello I encounter a small problem: how do I know that we are on the root menu?

the LCDML.MENU_getLayer () function returns 0 as the first sub-menu same for getID () and more generally the same for all the functions returning to a notion of position in the menus.

I thought, wrong that LCDML.MENU_getLayer () would return 255!

What solution is there?

Thank you in advance Best regards

Ps: sorry for my poor english

Jomelo commented 6 years ago

Hello, i have no problem with your english, my is not better :-)

The displayed menu is every a submenu. The main root element cannot be called or opened. The element with the id 255 is the root element.

The first submenu is on layer 0 (main displayed menu)

At the moment there is no direct call to check the root menu. All elements on layer 0 are on the first submenu .

The first element can be checked with:

if(LCDML.MENU_getLayer() == 0 && LCDML.MENU_getCursorPos() == 0 && LCDML.MENU_getCursorPosAbs() == 0 && LCDML.MENU_getScroll() == 0) 
{
 // ...
}
mavrickJ commented 6 years ago

Hello and thank you

In fact I will need to execute a piece of code, in the LCDML_control loop, only when one is on the root main menu, whatever the position of the cursor.

I looked a little and would it be possible in MENU_getParentId () to return a particular value for the root of the menu? of style uint8_t LCDMenuLib2 :: MENU_getParentId () / * **** **** * / { if (layer> 0 && layer <_LCDML_DISP_cfg_cursor_deep) { return _LCDML_NO_FUNC; } else return 255; }

It would not take all the cases but it would know that there is no parent level. What do you think about?

Best regards

RawLiquid commented 6 years ago

What he is trying to say is, using a menu function executes on every refresh, it’s the if statements that prevent things from happening....

On Sun, Jun 17, 2018 at 11:00 PM mavrickJ notifications@github.com wrote:

Hello and thank you

In fact I will need to execute a piece of code, in the LCDML_control loop, only when one is on the root main menu, whatever the position of the cursor.

I looked a little and would it be possible in MENU_getParentId () to return a particular value for the root of the menu? of style uint8_t LCDMenuLib2 :: MENU_getParentId () / * **** ****

  • / { if (layer> 0 && layer <_LCDML_DISP_cfg_cursor_deep) { return _LCDML_NO_FUNC; } else return 255; }

It would not take all the cases but it would know that there is no parent level. What do you think about?

Best regards

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Jomelo/LCDMenuLib2/issues/22#issuecomment-397949998, or mute the thread https://github.com/notifications/unsubscribe-auth/AEM5o5M3r5T7qbATs492wbiQ_bQM4WmAks5t90IZgaJpZM4UqxjP .

-- I respectfully decline the invitation to join your hallucination.

mavrickJ commented 6 years ago

It's exactly that Thank's for the translation. ;-)

mavrickJ commented 6 years ago

Hello, Thank you. finally i get around the difficulty by creating a global variable that i assign in each procedure and exit a boolean procedure. in the rest of the arborescence the problem does not arise, since I can use the function LCDML.MENU_getLayer ().

Thank you best regards