mirror of
https://github.com/s00500/ESPUI.git
synced 2025-06-14 02:30:41 +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)
|
||||
|
@ -142,6 +142,7 @@ public:
|
||||
bool visible;
|
||||
bool wide;
|
||||
bool vertical;
|
||||
bool enabled;
|
||||
uint16_t parentControl;
|
||||
String panelStyle;
|
||||
String elementStyle;
|
||||
@ -301,6 +302,8 @@ public:
|
||||
|
||||
void setPanelWide(uint16_t id, bool wide);
|
||||
void setVertical(uint16_t id, bool vert = true);
|
||||
void setEnabled(uint16_t id, bool enabled = true, int clientId = -1);
|
||||
|
||||
void updateVisibility(uint16_t id, bool visibility, int clientId = -1);
|
||||
|
||||
// Variables
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user