From 3afe1beaeb51834e832d3263ef79f078bc3d9a28 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 19 Jun 2022 13:52:56 +0200 Subject: [PATCH] GVarNumberEdit: fix editing GVAR NumberEdit would cap and set the value based on its own limits (-500;500). This is not possible anymore as the "setValue" method is now set when NumberEdit is visible and really used. --- radio/src/gui/colorlcd/gvar_numberedit.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/colorlcd/gvar_numberedit.cpp b/radio/src/gui/colorlcd/gvar_numberedit.cpp index 2576df3c5..73dedd88a 100644 --- a/radio/src/gui/colorlcd/gvar_numberedit.cpp +++ b/radio/src/gui/colorlcd/gvar_numberedit.cpp @@ -67,8 +67,7 @@ GVarNumberEdit::GVarNumberEdit(Window* parent, const rect_t& rect, int32_t vmin, num_field = new NumberEdit( this, rect_t{}, vmin, vmax, [=]() { return getValue() + voffset; }, - [=](int32_t newValue) { return setValue(newValue - voffset); }, - windowFlags, textFlags); + nullptr, windowFlags, textFlags); #if defined(GVARS) // The GVAR button @@ -130,13 +129,16 @@ void GVarNumberEdit::update() if (GV_IS_GV_VALUE(value, vmin, vmax)) { // GVAR mode act_field = gvar_field; + num_field->setSetValueHandler(nullptr); lv_obj_clear_flag(gvar_obj, LV_OBJ_FLAG_HIDDEN); lv_event_send(gvar_obj, LV_EVENT_VALUE_CHANGED, nullptr); } else { // number edit mode act_field = num_field; - lv_obj_clear_flag(num_obj, LV_OBJ_FLAG_HIDDEN); + num_field->setSetValueHandler( + [=](int32_t newValue) { return setValue(newValue - voffset); }); num_field->setValue(value + voffset); + lv_obj_clear_flag(num_obj, LV_OBJ_FLAG_HIDDEN); } if (has_focus) {