Skip to content

Commit

Permalink
Update activeWidget to be constrained within the range of available w…
Browse files Browse the repository at this point in the history
…idgets

Constrain activeWidget value to ensure it falls within the valid range of widgets.
  • Loading branch information
forntoh committed Oct 21, 2024
1 parent ce115de commit c5d8334
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/BaseItemManyWidgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BaseItemManyWidgets : public MenuItem {

public:
BaseItemManyWidgets(const char* text, BaseWidget** widgets, const uint8_t size, uint8_t activeWidget = 0)
: MenuItem(text), widgets(widgets), size(size), activeWidget(activeWidget) {}
: MenuItem(text), widgets(widgets), size(size), activeWidget(constrain(activeWidget, 0, size)) {}

uint8_t getActiveWidget() const { return activeWidget; }
void setActiveWidget(const uint8_t activeWidget) {
Expand Down

0 comments on commit c5d8334

Please sign in to comment.