ArduinoMenu icon indicating copy to clipboard operation
ArduinoMenu copied to clipboard

Text field with menu update

Open jeanvr-iff opened this issue 3 years ago • 0 comments

Hi, i was trying to make a text field with a string variable, and when pressed, the value should be modified and so the menu state. Something like this (i didn't find any method to create this functionality):

String number = "0000";
result updateNumberLabel(eventMask e)
{
    number = "1234";
    return proceed;
}

class altPrompt : public prompt
{
  public:
    altPrompt(constMEM promptShadow& p) : prompt(p) {}
    Used printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t panelNr) override {
      return out.printRaw(number.c_str(), len);
    }
};

MENU(
  numberSubMenu,
  "Number Text Field",
  doNothing,
  noEvent,
  noStyle,
  altOP(altPrompt, "", updateNumberLabel, enterEvent)
);

Basically, the number label only updates when i press any button to navigate after pressing on "altOP", i. e., when the updateNumberLabel is called.

jeanvr-iff avatar Jul 01 '22 18:07 jeanvr-iff