Fixes the defect that the software keyboard does not call onChangeEnd if the keyboard is hidden via touch and not via an esc. It changes TextEdit and FormField to move the onChange event to the base class instead of in TextEdit. Now the keyboard calls onChange when it is hidden.

This commit is contained in:
kevinkoenig
2021-09-17 20:33:23 +10:00
committed by Peter Feerick
parent 06fb5b0e18
commit ede2dba2ea
4 changed files with 15 additions and 8 deletions
+13
View File
@@ -32,6 +32,18 @@ class FormField: public Window
public:
FormField(Window * parent, const rect_t & rect, WindowFlags windowFlags = 0, LcdFlags textFlags = 0);
virtual void changeEnd(bool forceChanged = false)
{
if (changeHandler) {
changeHandler();
}
}
void setChangeHandler(std::function<void()> handler)
{
changeHandler = std::move(handler);
}
inline void setNextField(FormField *field)
{
next = field;
@@ -104,6 +116,7 @@ class FormField: public Window
FormField * previous = nullptr;
bool editMode = false;
bool enabled = true;
std::function<void()> changeHandler = nullptr;
};
class FormGroup: public FormField
-1
View File
@@ -37,7 +37,6 @@ coord_t calcScrollOffsetForField(FormField *newField, Window *topWindow)
bool Keyboard::attachKeyboard()
{
TRACE("ATTACH KEYBOARD");
if (activeKeyboard) {
if (activeKeyboard == this) return false;
activeKeyboard->clearField();
+1
View File
@@ -43,6 +43,7 @@ class Keyboard: public FormWindow
}
if (field) {
field->setEditMode(false);
field->changeEnd();
field = nullptr;
}
}
+1 -7
View File
@@ -42,11 +42,6 @@ class TextEdit : public FormField {
}
#endif
void setChangeHandler(std::function<void()> handler)
{
changeHandler = std::move(handler);
}
uint8_t getMaxLength() const
{
return length;
@@ -73,11 +68,10 @@ class TextEdit : public FormField {
uint8_t length;
const char * extra_chars;
uint8_t cursorPos = 0;
std::function<void()> changeHandler = nullptr;
void trim();
void changeEnd(bool forceChanged = false)
void changeEnd(bool forceChanged = false) override
{
cursorPos = 0;
if (changed || forceChanged) {