From bf3a4f6582bbccb0d390055ab61ec3b4ef578b4a Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 19 Jun 2020 12:52:16 +0200 Subject: [PATCH] Toggle the case in TextEdit --- radio/src/thirdparty/libopenui/src/textedit.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/textedit.cpp b/radio/src/thirdparty/libopenui/src/textedit.cpp index a3f8a1ecd..18c65c649 100644 --- a/radio/src/thirdparty/libopenui/src/textedit.cpp +++ b/radio/src/thirdparty/libopenui/src/textedit.cpp @@ -155,11 +155,14 @@ void TextEdit::onEvent(event_t event) case EVT_KEY_LONG(KEY_LEFT): case EVT_KEY_LONG(KEY_RIGHT): - if (v >= -26 && v <= 26) { - v = -v; // toggle case - if (event == EVT_KEY_LONG(KEY_LEFT)) { - killEvents(KEY_LEFT); - } + if (v >= 'A' && v <= 'Z') { + v += 32; // tolower + } + else if (v >= 'a' && v <= 'z') { + v -= 32; // toupper + } + if (event == EVT_KEY_LONG(KEY_LEFT)) { + killEvents(KEY_LEFT); } break; }