2025-07-18 2:51 AM - edited 2025-07-18 3:25 AM
Hello,
I've implemented, using the Designer, a Swipe container composed by 2 pages which are respectively 2 containers (SwipeContainerPage1, SwipeContainerPage2).
Each page includes some text and box which are updated on page swipe change and everything works fine.
Now I want to command an Action (a page change) when the user presses for a couple of seconds (let's say 2 seconds) SwipeContainerPage1 or SwipeContainerPage2 while maintaing the swiping property of this macro object.
Is this possible? I've taken as a reference the "ClickListener_Implementation_longPress" as a reference but with no success...
(Edited) I tried doing this and it works for the first page (calls goTo_GUITemperatureSet_Action()) but it blocks the swipe capability and I cannot go to the SwipeContainerPage2:
//In the .hpp file
class GUIMainSwipe_View : public GUIMainSwipe_ViewBase
{
public:
GUIMainSwipe_View();
virtual ~GUIMainSwipe_View() {}
virtual void setupScreen();
virtual void tearDownScreen();
virtual void handleTickEvent();
//container click handler
void containerClickHandler(const Container& c, const ClickEvent& evt);
protected:
Callback<GUIMainSwipe_View, const Container&, const ClickEvent&> containerClickedCallback;
uint8_t CurrSubPage;
bool SwipeContainerPage1_Pressed_status;
int SwipeContainerPage1_Pressed_timeout;
bool SwipeContainerPage2_Pressed_status;
int SwipeContainerPage2_Pressed_timeout;
};
//In the .cpp file
GUIMainSwipe_View::GUIMainSwipe_View():
containerClickedCallback(this, &GUIMainSwipe_View::containerClickHandler)
{
//Set curr sub page
CurrSubPage = SwipeContainer.getSelectedPage();
}
void GUIMainSwipe_View::setupScreen()
{
GUIMainSwipe_ViewBase::setupScreen();
//User init code
SwipeContainerPage1.setClickAction(containerClickedCallback);
SwipeContainerPage2.setClickAction(containerClickedCallback);
...
}
void GUIMainSwipe_View::containerClickHandler(const Container& c, const ClickEvent& evt)
{
if (&c == &SwipeContainerPage1)
{
if (evt.getType() == ClickEvent::PRESSED)
{
SwipeContainerPage1_Pressed_status = true;
}
else if (evt.getType() == ClickEvent::RELEASED)
{
SwipeContainerPage1_Pressed_status = false;
SwipeContainerPage1_Pressed_timeout = 0;
}
}
else if (&c == &SwipeContainerPage2)
{
if (evt.getType() == ClickEvent::PRESSED)
{
SwipeContainerPage2_Pressed_status = true;
}
else if (evt.getType() == ClickEvent::RELEASED)
{
SwipeContainerPage2_Pressed_status = false;
SwipeContainerPage2_Pressed_timeout = 0;
}
}
}
void GUIMainSwipe_View::handleTickEvent()
{
//Evaluate long press for page change
if (SwipeContainerPage1_Pressed_status == true)
{
SwipeContainerPage1_Pressed_timeout++;
if (SwipeContainerPage1_Pressed_timeout == GUIMAINSWIPE_BUTTON_LONG_PRESS_TIMEOUT)
{
goTo_GUITemperatureSet_Action();
SwipeContainerPage1_Pressed_status = false;
}
}
if (SwipeContainerPage2_Pressed_status == true)
{
SwipeContainerPage2_Pressed_timeout++;
if (SwipeContainerPage2_Pressed_timeout == GUIMAINSWIPE_BUTTON_LONG_PRESS_TIMEOUT)
{
goTo_GUITemperatureSet_Action();
SwipeContainerPage2_Pressed_status = false;
}
}
}
Any hint will be appreciated, thank you!