s00500/ESPUI

a "0" is displayed instead of the label o the button

borisgraell opened this issue · 6 comments

i was working with grouped controls, specifically, group buttons, at some point the string label of the first button was displaying a zero instead of the label, later i found out it happened to the first tab, too.

A sample of the code might help a bit. This has happened to me (not the zero but similar oddness). It usually means that you used a stack variable to initialize the string. since ESPUI uses pointers to strings, the strings need to remain in the calling code. I typically created a class wrapper around the controls to hold the strings I needed.

A sample of the code might help a bit. This has happened to me (not the zero but similar oddness). It usually means that you used a stack variable to initialize the string. since ESPUI uses pointers to strings, the strings need to remain in the calling code. I typically created a class wrapper around the controls to hold the strings I needed.

  uint16_t tab1 = ESPUI.addControl( ControlType::Tab, "Control", "Control" ); 
  uint16_t tab2 = ESPUI.addControl( ControlType::Tab, "Memoria Drills", "Guardar Drill" );         // id 02
  uint16_t tab3 = ESPUI.addControl( ControlType::Tab, "Memoria bolas", "Guardar bola" );     // id 03
  uint16_t tab4 = ESPUI.addControl( ControlType::Tab, "PROGR", "PROGR" ); // id 04

this is how i use the tab feature

but instead of "control" a 0 is display, just for the first tab

thank you in advance

edit: i deleted some of the grouped controls and the tab label showed again, maybe I'm using way too much of them?

All of those strings are stack variables. They do not have guaranteed persistence beyond the function scope.

This is how I do it:
static const PROGMEM char BACKUP_TAB_STR [] = "Backup";
uint16_t backupTab = ESPUI.addControl (ControlType::Tab, "BACKUP", BACKUP_TAB_STR);

Doing it this way saves ram end ensures the names do not change.
FYI: This may not be the issue you are facing. However, changing the order or the number of controls defined and having the symptoms change really does point to a persistence issue.

thank you Mr Mueller! i was grouping a slider to a button, i fixed the problem by doing it backwards, grouping buttons to a slider.

but i do like your way better, it would be easier to translate the frontend. i will give it a try

I normally create a label item and then group sliders, input fields and buttons to the label.

FYI: I have 9 tabs and up to 40 controls (some dynamically created and deleted) per tab. My smallest tab has 10 controles on it. Some of the improvements I have been making are due to having almost 300 controls on the UI.