menubackend library submenus

ok, then, here is my boy, girl,... example. Very simplified and reduced to one screen.

#include <LiquidCrystal.h>
#include "M2tk.h"
#include "m2ghlc.h"

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

uint8_t uiKeySelectPin = 10;
uint8_t uiKeyNextPin = 9;

uint8_t girl_color = 0;
uint8_t boy_color = 0;
uint8_t man_color = 0;

void fn_ok(m2_el_fnarg_p fnarg) {
  /* do something */
}

const char *fn_idx_to_color(uint8_t idx)
{
  switch(idx)
  {
    case 0: return "brown";
    case 1: return "blonde";
    case 2: return "red";
  }
  return "";
}


M2_LABEL(el_label1, NULL, "Boy:");
M2_COMBO(el_combo1, NULL, &boy_color, 3, fn_idx_to_color);

M2_LABEL(el_label2, NULL, "Girl: ");
M2_COMBO(el_combo2, NULL, &girl_color, 3, fn_idx_to_color);

M2_LABEL(el_label3, NULL, "Man: ");
M2_COMBO(el_combo3, NULL, &man_color, 3, fn_idx_to_color);

M2_BUTTON(el_ok, NULL, " ok ", fn_ok);

M2_LIST(list) = { 
    &el_label1, &el_combo1, 
    &el_label2, &el_combo2,  
    &el_label3, &el_combo3,  
    &el_ok 
};

M2_GRIDLIST(list_element, "c2",list);
M2tk m2(&list_element, m2_es_arduino, m2_eh_4bs, m2_gh_lc);

void setup() {
  m2_SetLiquidCrystal(&lcd, 16, 4);
  m2.setPin(M2_KEY_SELECT, uiKeySelectPin);
  m2.setPin(M2_KEY_NEXT, uiKeyNextPin);
}

void loop() {
  m2.checkKey();
  if ( m2.handleKey() )
    m2.draw();
  m2.checkKey();
}

The result will be stored in the three variables:

uint8_t girl_color = 0;
uint8_t boy_color = 0;
uint8_t man_color = 0;

I am not sure if i should repeat what is written in the reference manual. Maybe you should have a look at M2_GRIDLIST, which arranges the element into a matrix and M2_COMBO which does most of the work here.
So please let me know if there is something i can explain into more detail.

Remember: You can still use the serial monitor by replacing the event handler (eh) and the graphics handler (eh) as described in my last post.

Oliver