This commit is contained in:
Bertrand Songis
2019-10-04 15:14:43 +02:00
parent 17cff9546f
commit fbc8e01982
3 changed files with 7 additions and 1 deletions
+2
View File
@@ -31,6 +31,7 @@ void CheckBox::onKeyEvent(event_t event)
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event); TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
if (event == EVT_KEY_BREAK(KEY_ENTER)) { if (event == EVT_KEY_BREAK(KEY_ENTER)) {
onKeyPress();
setValue(!getValue()); setValue(!getValue());
invalidate({0, 0, 20, 20}); invalidate({0, 0, 20, 20});
} }
@@ -43,6 +44,7 @@ void CheckBox::onKeyEvent(event_t event)
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
bool CheckBox::onTouchEnd(coord_t x, coord_t y) bool CheckBox::onTouchEnd(coord_t x, coord_t y)
{ {
onKeyPress();
setValue(!getValue()); setValue(!getValue());
setFocus(); setFocus();
invalidate({0, 0, 20, 20}); invalidate({0, 0, 20, 20});
-1
View File
@@ -50,7 +50,6 @@ class CheckBox : public FormField {
#endif #endif
protected: protected:
const char * label;
std::function<uint8_t()> getValue; std::function<uint8_t()> getValue;
std::function<void(uint8_t)> setValue; std::function<void(uint8_t)> setValue;
}; };
+5
View File
@@ -38,10 +38,12 @@ void Slider::onKeyEvent(event_t event)
if (editMode) { if (editMode) {
if (event == EVT_ROTARY_RIGHT) { if (event == EVT_ROTARY_RIGHT) {
setValue(getValue() + rotencSpeed); setValue(getValue() + rotencSpeed);
onKeyPress();
return; return;
} }
else if (event == EVT_ROTARY_LEFT) { else if (event == EVT_ROTARY_LEFT) {
setValue(getValue() - rotencSpeed); setValue(getValue() - rotencSpeed);
onKeyPress();
return; return;
} }
} }
@@ -54,6 +56,7 @@ void Slider::onKeyEvent(event_t event)
bool Slider::onTouchStart(coord_t x, coord_t y) bool Slider::onTouchStart(coord_t x, coord_t y)
{ {
if (!hasFocus()) { if (!hasFocus()) {
onKeyPress();
setFocus(); setFocus();
} }
sliding = (value(x) == getValue()); sliding = (value(x) == getValue());
@@ -64,6 +67,7 @@ bool Slider::onTouchEnd(coord_t x, coord_t y)
{ {
setValue(value(x)); setValue(value(x));
invalidate(); invalidate();
onKeyPress();
return true; return true;
} }
@@ -74,6 +78,7 @@ bool Slider::onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY,
if (getValue() != newValue) { if (getValue() != newValue) {
setValue(newValue); setValue(newValue);
invalidate(); invalidate();
onKeyPress();
} }
} }
return true; return true;