mirror of
https://github.com/s00500/ESPUI.git
synced 2025-07-04 06:10:18 +00:00
Support dynamic enabling and disabling of controls
See documentation in README for how this works. This commit handles all the main controls. Pads are not yet supported.
This commit is contained in:
@ -783,6 +783,7 @@ void ESPUIClass::updateControl(Control* control, int clientId)
|
||||
root["id"] = control->id;
|
||||
root["visible"] = control->visible;
|
||||
root["color"] = (int)control->color;
|
||||
root["enabled"] = control->enabled;
|
||||
if (control->panelStyle != 0)
|
||||
root["panelStyle"] = control->panelStyle;
|
||||
if (control->elementStyle != 0)
|
||||
@ -855,6 +856,16 @@ void ESPUIClass::setPanelWide(uint16_t id, bool wide) {
|
||||
}
|
||||
}
|
||||
|
||||
void ESPUIClass::setEnabled(uint16_t id, bool enabled, int clientId) {
|
||||
Control* control = getControl(id);
|
||||
if (control)
|
||||
{
|
||||
control->enabled = enabled;
|
||||
updateControl(control, clientId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ESPUIClass::setVertical(uint16_t id, bool vert) {
|
||||
Control* control = getControl(id);
|
||||
if (control)
|
||||
@ -1108,6 +1119,7 @@ void ESPUIClass::prepareJSONChunk(AsyncWebSocketClient* client, uint16_t startin
|
||||
item["value"] = String(control->value);
|
||||
item["color"] = (int)control->color;
|
||||
item["visible"] = (int)control->visible;
|
||||
item["enabled"] = control->enabled;
|
||||
if (control->panelStyle != 0)
|
||||
item["panelStyle"] = String(control->panelStyle);
|
||||
if (control->elementStyle != 0)
|
||||
|
Reference in New Issue
Block a user