Spirik / GEM

Good Enough Menu for Arduino
GNU Lesser General Public License v3.0
245 stars 36 forks source link

From the main menu, if we press cancel, Launch a action from a item #31

Closed pailpoe closed 3 years ago

pailpoe commented 3 years ago

Hello Alexander, It's possible to add the possibility from the main menu when i press cancel to launch a item ( i want to launch my main context without the need to scroll up and click ok).

Thanks.

Spirik commented 3 years ago

That's an interesting idea! I see, how it can be useful. I will look into it.

Spirik commented 3 years ago

Added ability to specify an optional exitAction callback in GEMPage constructor in ver. 1.2.5!

GEMPage menuPageMain("Configuration", blinkMillis); // Main page with exit callback, that will be fired when pressing Cancel button

This can be any action, including those in which context is created. Action will be fired only for top-level menu page (i.e. menu page that has no parent) when not in edit mode and GEM_KEY_CANCEL is pressed.

Gist with auto-loaded context updated accordingly and can be found here.

There is slight difference between launching an action via button and launching an action through an exit callback: when launching an action via button current menu pointer position remains unchanged (i.e. button will still be in focus when menu is redrawn to the screen next time), whereas in case of an exit callback menu pointer position will be reset (i.e. set to the first menu item).

pailpoe commented 3 years ago

Thankyou, i will test this modification this week.

pailpoe commented 3 years ago

It’s perfect ! Happy Christmas

Spirik commented 3 years ago

Glad to hear!

Merry Christmas=) πŸŽ…πŸŽ„β„