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)
|
bool TabsCarousel::onTouchEnd(coord_t x, coord_t y)
|
||||||
{
|
{
|
||||||
unsigned index = (x - padding_left) / MENU_HEADER_BUTTON_WIDTH;
|
unsigned index = (x - padding_left) / MENU_HEADER_BUTTON_WIDTH;
|
||||||
|
if (index >= menu->tabs.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
menu->setCurrentTab(index);
|
menu->setCurrentTab(index);
|
||||||
setCurrentIndex(index);
|
setCurrentIndex(index);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ Widget::Widget(const WidgetFactory *factory, FormGroup *parent,
|
|||||||
focusGainedTS = RTOS_GET_MS();
|
focusGainedTS = RTOS_GET_MS();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setPressHandler([&]() -> uint8_t {
|
||||||
|
openWidgetMenu(this);
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::checkEvents()
|
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)
|
void Widget::paint(BitmapBuffer * dc)
|
||||||
{
|
{
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
@@ -91,17 +110,11 @@ void Widget::onEvent(event_t event)
|
|||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
TRACE("### event = 0x%x ###", event);
|
TRACE("### event = 0x%x ###", event);
|
||||||
if (!fullscreen) {
|
if (!fullscreen) {
|
||||||
switch(event) {
|
if (event == EVT_KEY_BREAK(KEY_EXIT)) {
|
||||||
// [ENTER] -> pop-up widget menu
|
|
||||||
case EVT_KEY_BREAK(KEY_ENTER):
|
|
||||||
killEvents(event);
|
|
||||||
openWidgetMenu(this);
|
|
||||||
return;
|
|
||||||
// [EXIT] -> exit focus mode (if not fullscreen)
|
// [EXIT] -> exit focus mode (if not fullscreen)
|
||||||
case EVT_KEY_BREAK(KEY_EXIT):
|
killEvents(event);
|
||||||
killEvents(event);
|
ViewMain::instance()->setFocus();
|
||||||
ViewMain::instance()->setFocus();
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// Forward the rest to the parent class
|
// Forward the rest to the parent class
|
||||||
Button::onEvent(event);
|
Button::onEvent(event);
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ class Widget : public Button
|
|||||||
// Window interface
|
// Window interface
|
||||||
void checkEvents() override;
|
void checkEvents() override;
|
||||||
void onEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
|
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer * dc) override;
|
||||||
|
|
||||||
// Widget interface
|
// Widget interface
|
||||||
|
|||||||
Reference in New Issue
Block a user