Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events on SELECT-submenu out of sync #424

Open
ScruffR opened this issue Aug 26, 2023 · 0 comments
Open

Events on SELECT-submenu out of sync #424

ScruffR opened this issue Aug 26, 2023 · 0 comments

Comments

@ScruffR
Copy link

ScruffR commented Aug 26, 2023

I have this setup

int length = settings.labelLen[settings.labelNr];
result changeLabel() { length = settings.labelLen[settings.labelNr]; return proceed; }
SELECT(settings.labelNr, selLabel, " Select Label ", changeLabel, anyEvent, wrapStyle
, VALUE("250g", 0, changeLabel, anyEvent)
, VALUE("500g", 1, changeLabel, anyEvent)
, VALUE("1kg ", 2, changeLabel, anyEvent)
);

result updateLength() { settings.labelLen[settings.labelNr] = length; return proceed; }
MENU(setLabel, " Label Settings         >", changeLabel, enterEvent, noStyle
, SUBMENU(selLabel)
, FIELD(length, "  length", " mm ", 10, 500, 10, 1, updateLength, exitEvent, noStyle)
, OP("< SAVE", storeData, enterEvent)
);

When I select and change the selected option in SUBMENU(selLabel) I'd like to reflect the current length setting for that label in the length field.
However, when I scroll through the options the length field only ever shows the corresponding value of the option that just lost the focus but not the on that gained focus.
Instead of anyEvent I also tried the more focused masks like focusEvent, ' enterEvent', ' updateEvent` and several combinations.

With anyEvent I also tried a more elaborate callback to see which events may render the desired combination of values

result changeLabel(eventMask event, navNode& nav, prompt &item) { 
  Serial.println(item.getText());
  Serial.println(event, HEX);
  Serial.println(settings.labelNr);
  Serial.println(settings.labelLen[settings.labelNr]);
  Serial.println();
  length = settings.labelLen[settings.labelNr]; 
  return proceed; 
}

but none of the events produced the correct combination between the displayed option and the respective index.

Sure, once I exit SUBMENU(selLabel) the FIELD(length, ...) gets updated correctly, but that's not exactly what I want.

What am I doing wrong? Or is this not possible at all?

BTW, despite root.useUpdateEvent = true; none of my updateEvent handlers gets called ever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant