fix(color): Long press and filtering in Switch Choice popup (#4362)

This commit is contained in:
philmoz
2023-11-27 22:02:41 +10:00
committed by GitHub
parent 2c3686882c
commit 3971a70d26
4 changed files with 15 additions and 5 deletions
+10 -3
View File
@@ -76,13 +76,13 @@ class SwitchChoiceMenuToolbar : public MenuToolbar
invertBtn->setPressHandler([=]() {
lv_obj_clear_state(invertBtn->getLvObj(), LV_STATE_FOCUSED);
longPress();
invertChoice();
return choice->inverted;
});
#endif
}
void longPress()
void invertChoice()
{
SwitchChoice* switchChoice = (SwitchChoice*)choice;
switchChoice->inverted = !switchChoice->inverted;
@@ -94,6 +94,14 @@ class SwitchChoiceMenuToolbar : public MenuToolbar
#endif
}
void longPress()
{
lv_indev_t* indev = lv_indev_get_act();
if (indev->driver->type == LV_INDEV_TYPE_KEYPAD) {
invertChoice();
}
}
protected:
MenuToolbarButton* invertBtn = nullptr;
};
@@ -153,7 +161,6 @@ SwitchChoice::SwitchChoice(Window* parent, const rect_t& rect, int vmin,
val = swtch;
}
if (val && (!isValueAvailable || isValueAvailable(val))) {
// if (filtered) fillMenu(menu);
tb->resetFilter();
menu->select(getIndexFromValue(val));
}
+2 -1
View File
@@ -39,12 +39,13 @@ class SwitchChoice : public Choice
protected:
friend SwitchChoiceMenuToolbar;
bool inverted = false;
bool inMenu = false;
void setValue(int value) override;
int getIntValue() const override;
void invertChoice();
#if defined(DEBUG_WINDOWS)
std::string getName() const override { return "SwitchChoice"; }
#endif