How does Clicklistener work?
Hello
I'm an amateur Touchgfx user.
I've completed many challenging tasks with Touchgfx, but I need a very simple one.
I want to set the output port high for the duration of a keystroke.
I used the ClickListener instructions in the program, but they didn't work.
I tried creating Box1 the same way and it works perfectly.
With this code, it works while I hold the button down, and stops when I release it, just as I wanted.
void BRHZLView::boxClickHandler( const Box& b, const ClickEvent& evt)
{
if (evt.getType() == ClickEvent::PRESSED) {
HAL_GPIO_WritePin(GPIOG, BZR_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOB, PST_I_Pin, GPIO_PIN_SET);
} else if(evt.getType() == ClickEvent::RELEASED){
HAL_GPIO_WritePin(GPIOG, BZR_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, PST_I_Pin, GPIO_PIN_RESET);
}
But the flexbutton group keeps giving definition errors, and the program won't compile.
I'm using Stm32h7b3i Evk, and the definitions in the base file don't match the definitions at https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/mixins.
The program gives an error.
Could you please provide a link to a sample program?
_Base.hpp
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#ifndef BRHZLVIEWBASE_HPP
#define BRHZLVIEWBASE_HPP
#include <gui/common/FrontendApplication.hpp>
#include <mvp/View.hpp>
#include <gui/brhzl_screen/BRHZLPresenter.hpp>
#include <touchgfx/widgets/Box.hpp>
#include <touchgfx/widgets/Image.hpp>
#include <touchgfx/widgets/BoxWithBorder.hpp>
#include <touchgfx/containers/buttons/Buttons.hpp>
#include <touchgfx/widgets/TextArea.hpp>
#include <touchgfx/mixins/ClickListener.hpp>
#include <touchgfx/widgets/TextAreaWithWildcard.hpp>
class BRHZLViewBase : public touchgfx::View<BRHZLPresenter>
{
public:
BRHZLViewBase();
virtual ~BRHZLViewBase();
virtual void setupScreen();
/*
* Virtual Action Handlers
*/
virtual void P_Gde()
{
// Override and implement this function in BRHZL
}
virtual void P_ILR()
{
// Override and implement this function in BRHZL
}
virtual void P_GRI()
{
// Override and implement this function in BRHZL
}
protected:
FrontendApplication& application() {
return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
}
/*
* Member Declarations
*/
touchgfx::Box __background;
touchgfx::Image image1;
touchgfx::BoxWithBorder boxWithBorder1;
touchgfx::ImageButtonStyle< touchgfx::TouchButtonTrigger > bck2;
touchgfx::TextArea textArea1;
touchgfx::TextArea textArea2;
touchgfx::Image image2;
touchgfx::ClickListener< touchgfx::TextButtonStyle< touchgfx::ImageButtonStyle< touchgfx::TouchButtonTrigger > > > P_ileri;
touchgfx::ClickListener< touchgfx::TextButtonStyle< touchgfx::ImageButtonStyle< touchgfx::TouchButtonTrigger > > > P_geri;
touchgfx::ClickListener< touchgfx::Box > box1;
touchgfx::TextArea pgmi;
touchgfx::ImageButtonStyle< touchgfx::ToggleButtonTrigger > pg_ok;
touchgfx::TextAreaWithOneWildcard hrkt_bar;
touchgfx::TextButtonStyle< touchgfx::ImageButtonStyle< touchgfx::TouchButtonTrigger > > ileri2;
touchgfx::ClickListener< touchgfx::TextButtonStyle< touchgfx::BoxWithBorderButtonStyle< touchgfx::ClickButtonTrigger > > > button1;
/*
* Wildcard Buffers
*/
static const uint16_t HRKT_BAR_SIZE = 10;
touchgfx::Unicode::UnicodeChar hrkt_barBuffer[HRKT_BAR_SIZE];
private:
/*
* Callback Declarations
*/
touchgfx::Callback<BRHZLViewBase, const touchgfx::AbstractButtonContainer&> flexButtonCallback;
/*
* Callback Handler Declarations
*/
void flexButtonCallbackHandler(const touchgfx::AbstractButtonContainer& src);
};
#endif // BRHZLVIEWBASE_HPP

