diff --git a/module-apps/application-notes/windows/NotesEditWindow.cpp b/module-apps/application-notes/windows/NotesEditWindow.cpp index 457be6e28..e4e91cae1 100644 --- a/module-apps/application-notes/windows/NotesEditWindow.cpp +++ b/module-apps/application-notes/windows/NotesEditWindow.cpp @@ -56,6 +56,13 @@ void NotesEditWindow::buildInterface() { text->setFont("gt_pressura_bold_24"); text->setRadius(5); text->setMargins( gui::Margins(10, 10, 10, 10)); + text->activatedCallback = [=] (gui::Item& item){ + LOG_INFO("Comparing text" ); + LOG_INFO("SOURCE:[%s]", textString.c_str()); + UTF8 getstr = text->getText(); + LOG_INFO("GETSTR:[%s]", getstr.c_str()); + LOG_INFO("COMPARE: %s",(textString==getstr?"TRUE":"FALSE")); + return true; }; topBar->setActive(TopBar::Elements::TIME, true ); @@ -85,13 +92,7 @@ bool NotesEditWindow::onInput( const InputEvent& inputEvent ) { if( inputEvent.keyCode != KeyCode::KEY_ENTER ) { application->render( RefreshModes::GUI_REFRESH_FAST ); } - //if enter was pressed - else { - LOG_INFO("SOURCE:[%s]", textString.c_str()); - UTF8 getstr = text->getText(); - LOG_INFO("GETSTR:[%s]", getstr.c_str()); - LOG_INFO("COMPARE: %s",(textString==getstr?"TRUE":"FALSE")); - } + return true; } diff --git a/module-gui/gui/widgets/Text.cpp b/module-gui/gui/widgets/Text.cpp index 1155766b8..43df2cd32 100644 --- a/module-gui/gui/widgets/Text.cpp +++ b/module-gui/gui/widgets/Text.cpp @@ -114,6 +114,7 @@ UTF8 Text::getText() { auto it = textLines.begin(); while( it != textLines.end()) { + auto textLine = (*it); output += (*it)->text; if( (*it)->endType == LineEndType::BREAK ) { output.insert("\n"); @@ -392,6 +393,11 @@ bool Text::onInput( const InputEvent& inputEvent ) { return false; } + //if key has enter code than return + if( inputEvent.keyCode == KeyCode::KEY_ENTER ) + return false; + + //check if this is navigation event bool res; if( editMode == EditMode::BROWSE ) @@ -430,6 +436,7 @@ bool Text::onInput( const InputEvent& inputEvent ) { } bool Text::onActivated( void* data ) { + Rect::onActivated( data ); return false; } diff --git a/module-utils/utf8/UTF8.cpp b/module-utils/utf8/UTF8.cpp index d64121b35..9ece84bd1 100644 --- a/module-utils/utf8/UTF8.cpp +++ b/module-utils/utf8/UTF8.cpp @@ -311,7 +311,8 @@ UTF8& UTF8::operator+=( const UTF8& utf ) { data = newData; sizeAllocated = newSizeAllocated; strLength += utf.strLength; - sizeUsed += utf.sizeUsed; + //-1 is to ignore double null terminator as it is counted in sizeUsed + sizeUsed += utf.sizeUsed-1; lastIndex = 0; lastIndexData = data; }