Skip to main content
Tnguy.3
Associate II
November 3, 2021
Question

Having a hard time getting ClickListener Mixins working from TouchGFX

  • November 3, 2021
  • 0 replies
  • 537 views

Hi guys,

I'm trying to make a Text Area work like a button by adding a ClickListener Mixin to it. I tried to follow this guide but for some reason, every time I click the label, it doesn't do anything (I added a print and it doesnt print).

HPP

#ifndef SCREEN2VIEW_HPP
#define SCREEN2VIEW_HPP
 
#include <gui_generated/screen2_screen/Screen2ViewBase.hpp>
#include <gui/screen2_screen/Screen2Presenter.hpp>
 
class Screen2View : public Screen2ViewBase
{
public:
 Screen2View();
 virtual ~Screen2View() {}
 virtual void setupScreen();
 virtual void tearDownScreen();
 
protected:
private:
 touchgfx::ClickListener< touchgfx::TextArea > backLbl;
 Callback<Screen2View, const TextArea&, const ClickEvent&> LblClickedCallback;
 
 void lblClickHandler(const touchgfx::TextArea& l, const touchgfx::ClickEvent& e);
};
 
#endif // SCREEN2VIEW_HPP

CPP:

#include <gui/screen2_screen/Screen2View.hpp>
 
Screen2View::Screen2View() : LblClickedCallback(this, &Screen2View::lblClickHandler) // binding callback to the view
{
 backLbl.setClickAction(LblClickedCallback);
}
 
void Screen2View::setupScreen()
{
 Screen2ViewBase::setupScreen();
}
 
void Screen2View::tearDownScreen()
{
 Screen2ViewBase::tearDownScreen();
}
 
void Screen2View::lblClickHandler(const TextArea& l, const ClickEvent& e)
{
 if (&l == &backLbl)
 {
 // does not work
 application().gotoScreen1ScreenNoTransition();
 touchgfx_printf("Label clicked\n");
 }
 touchgfx_printf("clicked\n");
}

I'm not sure what's wrong... Also, do anyone know where I can find a guide for the Draggable Mixin? I'm looking for a drag horizontal event to change a progress bar value.

This topic has been closed for replies.