button: set focus before onPress()

onPress() might create a new window or change the focus.
This commit is contained in:
Raphael Coeffic
2022-06-11 15:13:11 +02:00
committed by Raphael Coeffic
parent a20792a211
commit d64b024381
+2 -3
View File
@@ -78,12 +78,11 @@ void Button::onEvent(lv_event_t* event)
TRACE_WINDOWS("%s received lvgl event code 0x%X", getWindowDebugString("Button").c_str(), code);
if (enabled && code == LV_EVENT_CLICKED) {
onKeyPress();
onPress();
if (!(windowFlags & NO_FOCUS)) {
setFocus(SET_FOCUS_DEFAULT);
}
onKeyPress();
onPress();
}
}