diff --git a/src/ESPUI.cpp b/src/ESPUI.cpp index bcc16d8..b824b53 100644 --- a/src/ESPUI.cpp +++ b/src/ESPUI.cpp @@ -87,7 +87,7 @@ void ESPUIClass::label(const char *label, String value) { 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 (debug) Serial.println("UI ERROR: Element " + String(label) + " exists, skipping creating element!"); return; @@ -96,6 +96,12 @@ void ESPUIClass::button(const char *label, void (*callBack)(Control*, int)) { Control *newB = new Control(); newB->type = UI_BUTTON; newB->label = label; + + if (value != "") + newB->value = value; // Init with labeltext + else + newB->value = String(label); + newB->callback = callBack; newB->id = cIndex; controls[cIndex] = newB; diff --git a/src/ESPUI.h b/src/ESPUI.h index 2a97372..0eb5e35 100644 --- a/src/ESPUI.h +++ b/src/ESPUI.h @@ -63,7 +63,7 @@ void begin(const char* _title); // Setup servers and page // Creating Elements 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 pad(const char* label, bool centerButton, void (* callBack)(Control*, int)); // Create Pad Control