Fix sliding on inactive part of tab bar grabbing input focus (#1180)

* fix #298, keys not working, after sliding on tabs bar

* fix for touch end event with start x,y coordinate is triggered after the last slide event

* remove selecting tabs on the tab top bar by sliding as it does break sliding the tab bar.
This commit is contained in:
Malte Langermann
2021-11-29 12:07:22 +11:00
committed by GitHub
parent b8335b994f
commit 15233e1add
2 changed files with 28 additions and 0 deletions
+23
View File
@@ -71,16 +71,39 @@ void TabsCarousel::paint(BitmapBuffer * dc)
}
#if defined(HARDWARE_TOUCH)
bool TabsCarousel::onTouchStart(coord_t x, coord_t y)
{
if(sliding)
sliding = false;
return true;
}
bool TabsCarousel::onTouchEnd(coord_t x, coord_t y)
{
if(sliding)
return true;
unsigned index = (x - padding_left) / MENU_HEADER_BUTTON_WIDTH;
if (index >= menu->tabs.size()) {
return false;
}
menu->setCurrentTab(index);
setCurrentIndex(index);
return true;
}
bool TabsCarousel::onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY, coord_t slideX, coord_t slideY)
{
sliding = true;
Window::onTouchSlide(x,y,startX,startY,slideX,slideY);
menu->setCurrentTab(currentIndex);
return true;
}
#endif
TabsGroup::TabsGroup(uint8_t icon):
+5
View File
@@ -102,13 +102,18 @@ class TabsCarousel: public Window {
void paint(BitmapBuffer * dc) override;
#if defined(HARDWARE_TOUCH)
bool onTouchStart(coord_t x, coord_t y) override;
bool onTouchEnd(coord_t x, coord_t y) override;
bool onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY, coord_t slideX, coord_t slideY) override;
#endif
protected:
constexpr static uint8_t padding_left = 3;
TabsGroup * menu;
uint8_t currentIndex = 0;
#if defined(HARDWARE_TOUCH)
bool sliding = false;
#endif
};
class TabsGroupHeader: public FormGroup {