diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 85c622917..5bf55362a 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -71,6 +71,9 @@ along with this program. If not, see . using namespace meshtastic; /** @todo remove */ +String alertBannerMessage = ""; +uint32_t alertBannerUntil = 0; + namespace graphics { @@ -3826,8 +3829,8 @@ void Screen::setFrames(FrameFocus focus) ui->setFrames(normalFrames, numframes); ui->disableAllIndicators(); - // Add function overlay here. This can show when notifications muted, modifier key is active etc - static OverlayCallback overlays[] = {drawFunctionOverlay, drawCustomFrameIcons, drawAlertBannerOverlay}; + // Add overlays: frame icons and alert banner) + static OverlayCallback overlays[] = {drawCustomFrameIcons, drawAlertBannerOverlay}; ui->setOverlays(overlays, sizeof(overlays) / sizeof(overlays[0])); prevFrame = -1; // Force drawNodeInfo to pick a new node (because our list diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index 9db389296..005c0fa02 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -703,4 +703,7 @@ class Screen : public concurrency::OSThread } // namespace graphics +extern String alertBannerMessage; +extern uint32_t alertBannerUntil; + #endif \ No newline at end of file diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index a91163482..4246f000c 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -202,6 +202,28 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) // source at all) return 0; } + + // === Toggle Destination Selector with Tab === + if (event->kbchar == 0x09) { + if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_NODE) { + // Exit selection + this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; + this->runState = CANNED_MESSAGE_RUN_STATE_FREETEXT; + } else { + // Enter selection + this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NODE; + this->destIndex = 0; + this->scrollIndex = 0; + this->runState = CANNED_MESSAGE_RUN_STATE_DESTINATION_SELECTION; + } + + UIFrameEvent e; + e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; + this->notifyObservers(&e); + screen->forceDisplay(); + return 0; + } + if (this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) { return 0; // Ignore input while sending } @@ -435,9 +457,17 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) validEvent = true; } if (event->inputEvent == static_cast(ANYKEY)) { - // when inactive, this will switch to the freetext mode - if ((this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) || - (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)) { + // Prevent entering freetext mode while overlay banner is showing + extern String alertBannerMessage; + extern uint32_t alertBannerUntil; + if (alertBannerMessage.length() > 0 && (alertBannerUntil == 0 || millis() <= alertBannerUntil)) { + return 0; + } + + if ((this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE || + this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE || + this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) && + (event->kbchar >= 32 && event->kbchar <= 126)) { this->runState = CANNED_MESSAGE_RUN_STATE_FREETEXT; }