Select the widget when touched prior to firing up the menu
This commit is contained in:
committed by
Raphael Coeffic
parent
a369f83f13
commit
a01a22c96f
@@ -69,6 +69,9 @@ void TabsCarousel::paint(BitmapBuffer * dc)
|
||||
bool TabsCarousel::onTouchEnd(coord_t x, coord_t y)
|
||||
{
|
||||
unsigned index = (x - padding_left) / MENU_HEADER_BUTTON_WIDTH;
|
||||
if (index >= menu->tabs.size()) {
|
||||
return false;
|
||||
}
|
||||
menu->setCurrentTab(index);
|
||||
setCurrentIndex(index);
|
||||
return true;
|
||||
|
||||
@@ -48,6 +48,11 @@ Widget::Widget(const WidgetFactory *factory, FormGroup *parent,
|
||||
focusGainedTS = RTOS_GET_MS();
|
||||
}
|
||||
});
|
||||
|
||||
setPressHandler([&]() -> uint8_t {
|
||||
openWidgetMenu(this);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
void Widget::checkEvents()
|
||||
@@ -60,6 +65,20 @@ void Widget::checkEvents()
|
||||
}
|
||||
}
|
||||
|
||||
bool Widget::onTouchEnd(coord_t x, coord_t y)
|
||||
{
|
||||
TRACE_WINDOWS("Widget received touch end (%d) x=%d;y=%d",
|
||||
hasFocus(), x, y);
|
||||
|
||||
if (hasFocus()) {
|
||||
onPress();
|
||||
return true;
|
||||
}
|
||||
|
||||
setFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Widget::paint(BitmapBuffer * dc)
|
||||
{
|
||||
if (fullscreen) {
|
||||
@@ -91,17 +110,11 @@ void Widget::onEvent(event_t event)
|
||||
#if defined(HARDWARE_KEYS)
|
||||
TRACE("### event = 0x%x ###", event);
|
||||
if (!fullscreen) {
|
||||
switch(event) {
|
||||
// [ENTER] -> pop-up widget menu
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
killEvents(event);
|
||||
openWidgetMenu(this);
|
||||
return;
|
||||
if (event == EVT_KEY_BREAK(KEY_EXIT)) {
|
||||
// [EXIT] -> exit focus mode (if not fullscreen)
|
||||
case EVT_KEY_BREAK(KEY_EXIT):
|
||||
killEvents(event);
|
||||
ViewMain::instance()->setFocus();
|
||||
return;
|
||||
killEvents(event);
|
||||
ViewMain::instance()->setFocus();
|
||||
return;
|
||||
}
|
||||
// Forward the rest to the parent class
|
||||
Button::onEvent(event);
|
||||
|
||||
@@ -84,6 +84,7 @@ class Widget : public Button
|
||||
// Window interface
|
||||
void checkEvents() override;
|
||||
void onEvent(event_t event) override;
|
||||
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||
void paint(BitmapBuffer * dc) override;
|
||||
|
||||
// Widget interface
|
||||
|
||||
Reference in New Issue
Block a user