Use EVT_KEY_FIRST on Button

This commit is contained in:
Raphael Coeffic
2021-05-23 08:48:17 +02:00
parent 52b3388062
commit 18025279c1
2 changed files with 7 additions and 4 deletions
+2 -1
View File
@@ -36,7 +36,8 @@ void Button::onEvent(event_t event)
{
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString("Button").c_str(), event);
if (enabled && event == EVT_KEY_BREAK(KEY_ENTER)) {
if (enabled && event == EVT_KEY_FIRST(KEY_ENTER)) {
killEvents(event);
onKeyPress();
onPress();
}
+5 -3
View File
@@ -28,9 +28,11 @@ constexpr WindowFlags BUTTON_CHECKED_ON_FOCUS = FORM_FLAGS_LAST << 3u;
class Button: public FormField
{
public:
Button(FormGroup * parent, const rect_t & rect, std::function<uint8_t(void)> pressHandler = nullptr, WindowFlags windowFlags = 0, LcdFlags textFlags = 0):
FormField(parent, rect, windowFlags, textFlags),
pressHandler(std::move(pressHandler))
Button(FormGroup* parent, const rect_t& rect,
std::function<uint8_t(void)> pressHandler = nullptr,
WindowFlags windowFlags = 0, LcdFlags textFlags = 0) :
FormField(parent, rect, windowFlags, textFlags),
pressHandler(std::move(pressHandler))
{
}