diff --git a/radio/src/gui/colorlcd/choiceex.cpp b/radio/src/gui/colorlcd/choiceex.cpp index 8bf86b6f0..735f03b65 100644 --- a/radio/src/gui/colorlcd/choiceex.cpp +++ b/radio/src/gui/colorlcd/choiceex.cpp @@ -58,10 +58,33 @@ bool ChoiceEx::onTouchStart(coord_t x, coord_t y) return Choice::onTouchStart(x, y); } -bool ChoiceEx::onTouchEnd(coord_t x, coord_t y) +bool ChoiceEx::isLongPress() { tmr10ms_t curTimer = get_tmr10ms(); - if (duration10ms != 0 && curTimer - duration10ms > LONG_PRESS_10MS) { + return (duration10ms != 0 && curTimer - duration10ms > LONG_PRESS_10MS); +} + +void ChoiceEx::checkEvents(void) +{ + event_t event = getEvent(); + + if (isLongPress()) { + if (longPressHandler) { + longPressHandler(event); + duration10ms = 0; + } + } + + if (hasFocus()) + onEvent(event); + else + pushEvent(event); +} + + +bool ChoiceEx::onTouchEnd(coord_t x, coord_t y) +{ + if (isLongPress()) { if (longPressHandler) { longPressHandler(0); duration10ms = 0; diff --git a/radio/src/gui/colorlcd/choiceex.h b/radio/src/gui/colorlcd/choiceex.h index 23cee0514..5a3f33cda 100644 --- a/radio/src/gui/colorlcd/choiceex.h +++ b/radio/src/gui/colorlcd/choiceex.h @@ -33,6 +33,8 @@ class ChoiceEx : public Choice #if defined(HARDWARE_TOUCH) bool onTouchEnd(coord_t x, coord_t y) override; bool onTouchStart(coord_t x, coord_t y) override; + void checkEvents(void) override; + bool isLongPress(); #endif #if defined(DEBUG_WINDOWS)