M module-gui/gui/input/Translator.cpp => module-gui/gui/input/Translator.cpp +3 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "Translator.hpp"
@@ 194,7 194,7 @@ namespace gui
return InputEvent{key, InputEvent::State::keyReleasedLong, getKeyCode(key.keyCode)};
}
- uint32_t KeyInputMappedTranslation::handle(RawKey key, const std::string &keymap)
+ uint32_t KeyInputMappedTranslation::handle(RawKey key, const std::string &keymap, bool incrementTimes)
{
// get shortpress
if (previousKeyPress.keyCode != key.keyCode) {
@@ 202,7 202,7 @@ namespace gui
}
else if (key.state == RawKey::State::Released) {
if (key.timeRelease - previousKeyPress.timeRelease < keyTimeCycleMs) {
- ++times;
+ incrementTimes ? ++times : times;
}
else {
times = 0;
M module-gui/gui/input/Translator.hpp => module-gui/gui/input/Translator.hpp +2 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 69,7 69,7 @@ namespace gui
Profiles profiles;
public:
- uint32_t handle(RawKey key, const std::string &keymap);
+ uint32_t handle(RawKey key, const std::string &keymap, bool incrementTimes = true);
uint32_t getTimes() const noexcept;
};
M module-gui/gui/widgets/text/Text.cpp => module-gui/gui/widgets/text/Text.cpp +2 -0
@@ 615,6 615,7 @@ namespace gui
setCursorStartPosition(CursorStartPosition::Offset);
if (!document->isEmpty() && removeChar()) {
+ translator.resetPreviousKeyPress();
onTextChanged();
}
return true;
@@ 653,6 654,7 @@ namespace gui
/// if we have multi press in non digit mode - we need to replace char and put next char from translator
if (!(inputMode->is(InputMode::digit) || (inputMode->is(InputMode::phone))) && translator.getTimes() > 0) {
removeChar();
+ code = translator.handle(inputEvent.getRawKey(), getInputModeKeyMap(), false);
}
addChar(code);
onTextChanged();