From 5fecafd4f91c072b655768012328b09943dc354a Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Wed, 13 May 2026 18:28:04 +0200 Subject: [PATCH] fix: KeyboardWidget preview buffer size and KEY_CONTEXT_MENU handling - preview[] increased from 32 to 40 bytes to safely fit max label (15 chars) + 20 chars text + cursor + null without snprintf truncation - KEY_CONTEXT_MENU (long-press ENTER) now treated as CANCEL in keyboard input handler, restoring BotScreen behavior lost in the refactor Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/ui-new/KeyboardWidget.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/companion_radio/ui-new/KeyboardWidget.h b/examples/companion_radio/ui-new/KeyboardWidget.h index 56803a7d..44733404 100644 --- a/examples/companion_radio/ui-new/KeyboardWidget.h +++ b/examples/companion_radio/ui-new/KeyboardWidget.h @@ -55,7 +55,7 @@ struct KeyboardWidget { const char* disp_start = buf; int disp_len = len; if (disp_len > 20) { disp_start = buf + (disp_len - 20); disp_len = 20; } - char preview[32]; + char preview[40]; snprintf(preview, sizeof(preview), "%s%.*s_", label, disp_len, disp_start); display.setCursor(0, KB_TEXT_Y); display.print(preview); @@ -147,7 +147,7 @@ struct KeyboardWidget { return NONE; } - if (c == KEY_CANCEL) return CANCELLED; + if (c == KEY_CANCEL || c == KEY_CONTEXT_MENU) return CANCELLED; if (c == KEY_UP) { if (row > 0) {