1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-22 04:00:55 +00:00

send button value for button text

This commit is contained in:
Lukas Bachschwell 2017-11-13 17:22:02 +01:00
parent 3c26def22a
commit 6d206d21f9
2 changed files with 8 additions and 2 deletions

View File

@ -87,7 +87,7 @@ void ESPUIClass::label(const char *label, String value) {
cIndex++; cIndex++;
} }
void ESPUIClass::button(const char *label, void (*callBack)(Control*, int)) { void ESPUIClass::button(const char *label, void (*callBack)(Control*, int), String value) {
if (labelExists(label)) { if (labelExists(label)) {
if (debug) Serial.println("UI ERROR: Element " + String(label) + " exists, skipping creating element!"); if (debug) Serial.println("UI ERROR: Element " + String(label) + " exists, skipping creating element!");
return; return;
@ -96,6 +96,12 @@ void ESPUIClass::button(const char *label, void (*callBack)(Control*, int)) {
Control *newB = new Control(); Control *newB = new Control();
newB->type = UI_BUTTON; newB->type = UI_BUTTON;
newB->label = label; newB->label = label;
if (value != "")
newB->value = value; // Init with labeltext
else
newB->value = String(label);
newB->callback = callBack; newB->callback = callBack;
newB->id = cIndex; newB->id = cIndex;
controls[cIndex] = newB; controls[cIndex] = newB;

View File

@ -63,7 +63,7 @@ void begin(const char* _title); // Setup servers and page
// Creating Elements // Creating Elements
void label(const char* label, String value = ""); // Create Label void label(const char* label, String value = ""); // Create Label
void button(const char* label, void (* callBack)(Control*, int)); // Create Event Button void button(const char* label, void (* callBack)(Control*, int), String value = ""); // Create Event Button
void switcher(const char* label, bool startState, void (* callBack)(Control*, int)); // Create Toggle Button void switcher(const char* label, bool startState, void (* callBack)(Control*, int)); // Create Toggle Button
void pad(const char* label, bool centerButton, void (* callBack)(Control*, int)); // Create Pad Control void pad(const char* label, bool centerButton, void (* callBack)(Control*, int)); // Create Pad Control