cancel
Showing results for 
Search instead for 
Did you mean: 

how to use text area click listener

M3R
Associate II

hello

i want to use click listener for text area

i add this function:

	void textareaClickHandler(const TextArea& b, const ClickEvent& e);

and this :

	Callback<startupViewBase, const TextArea&, const ClickEvent&> textareaClickedCallback;

to viewbase.hpp

/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#ifndef STARTUPVIEWBASE_HPP
#define STARTUPVIEWBASE_HPP
 
#include <gui/common/FrontendApplication.hpp>
#include <mvp/View.hpp>
#include <gui/startup_screen/startupPresenter.hpp>
#include <touchgfx/widgets/Box.hpp>
#include <touchgfx/widgets/AnimatedImage.hpp>
#include <touchgfx/widgets/TextAreaWithWildcard.hpp>
#include <touchgfx/widgets/TextArea.hpp>
#include <touchgfx/containers/ScrollableContainer.hpp>
#include <touchgfx/widgets/ButtonWithLabel.hpp>
#include <touchgfx/mixins/Draggable.hpp>
#include <touchgfx/mixins/ClickListener.hpp>
 
class startupViewBase : public touchgfx::View<startupPresenter>
{
public:
    startupViewBase();
    virtual ~startupViewBase() {}
    virtual void setupScreen();
	void textareaClickHandler(const TextArea& b, const ClickEvent& e);
    /*
     * Virtual Action Handlers
     */
    virtual void function1()
    {
        // Override and implement this function in startup
    }
 
protected:
    FrontendApplication& application() {
        return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
    }
 
	Callback<startupViewBase, const TextArea&, const ClickEvent&> textareaClickedCallback;
    /*
     * Member Declarations
     */
    touchgfx::Box box1;
    touchgfx::Draggable< touchgfx::AnimatedImage > animatedImage1;
    touchgfx::TextAreaWithOneWildcard textArea1;
    touchgfx::TextArea textArea2;
    touchgfx::TextArea textArea3;
    touchgfx::TextArea ap_available;
    touchgfx::ScrollableContainer scrollableContainer1;
    touchgfx::ClickListener< touchgfx::TextArea > ap6;
    touchgfx::ClickListener< touchgfx::TextArea > ap5;
    touchgfx::ClickListener< touchgfx::TextArea > ap4;
    touchgfx::ClickListener< touchgfx::TextArea > ap3;
    touchgfx::ClickListener< touchgfx::TextArea > ap2;
    touchgfx::ClickListener< touchgfx::TextArea > ap1;
    touchgfx::ButtonWithLabel buttonWithLabel1;
 
private:
 
    /*
     * Callback Declarations
     */
    touchgfx::Callback<startupViewBase, const touchgfx::AbstractButton&> buttonCallback;
 
    /*
     * Callback Handler Declarations
     */
    void buttonCallbackHandler(const touchgfx::AbstractButton& src);
 
};
 
#endif // STARTUPVIEWBASE_HPP

and when i add this function :

textareaClickedCallback(this, &startupViewBase::textareaClickHandler)

to view base.cpp :

/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/startup_screen/startupViewBase.hpp>
#include <touchgfx/Color.hpp>
#include "BitmapDatabase.hpp"
#include <texts/TextKeysAndLanguages.hpp>
 
startupViewBase::startupViewBase() :
    buttonCallback(this, &startupViewBase::buttonCallbackHandler),
	textareaClickedCallback(this, &startupViewBase::textareaClickHandler)
{
 
    box1.setPosition(0, 0, 800, 480);
    box1.setColor(touchgfx::Color::getColorFrom24BitRGB(0, 0, 0));
 
    animatedImage1.setXY(468, 24);
    animatedImage1.setBitmaps(BITMAP_WIFI00_ID, BITMAP_WIFI47_ID);
    animatedImage1.setUpdateTicksInterval(3);
    animatedImage1.startAnimation(false, true, true);
 
    textArea1.setXY(274, 609);
    textArea1.setVisible(false);
    textArea1.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 0, 0));
    textArea1.setLinespacing(0);
    textArea1.setTypedText(touchgfx::TypedText(T_SINGLEUSEID143));
 
    textArea2.setXY(393, 602);
    textArea2.setColor(touchgfx::Color::getColorFrom24BitRGB(0, 0, 0));
    textArea2.setLinespacing(0);
    textArea2.setTypedText(touchgfx::TypedText(T_SINGLEUSEID141));
 
    textArea3.setXY(149, 602);
    textArea3.setColor(touchgfx::Color::getColorFrom24BitRGB(0, 0, 0));
    textArea3.setLinespacing(0);
    textArea3.setTypedText(touchgfx::TypedText(T_SINGLEUSEID142));
 
    ap_available.setXY(494, 9);
    ap_available.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    ap_available.setLinespacing(0);
    ap_available.setTypedText(touchgfx::TypedText(T_SINGLEUSEID144));
 
    scrollableContainer1.setPosition(10, 58, 278, 127);
    scrollableContainer1.setScrollbarsColor(touchgfx::Color::getColorFrom24BitRGB(0, 0, 0));
 
    ap6.setXY(13, 266);
    ap6.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    ap6.setLinespacing(0);
    ap6.setAlpha(150);
    ap6.setTypedText(touchgfx::TypedText(T_SINGLEUSEID155));
    scrollableContainer1.add(ap6);
 
    ap5.setXY(13, 215);
    ap5.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    ap5.setLinespacing(0);
    ap5.setAlpha(150);
    ap5.setTypedText(touchgfx::TypedText(T_SINGLEUSEID154));
    scrollableContainer1.add(ap5);
 
    ap4.setXY(13, 163);
    ap4.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    ap4.setLinespacing(0);
    ap4.setAlpha(150);
    ap4.setTypedText(touchgfx::TypedText(T_SINGLEUSEID153));
    scrollableContainer1.add(ap4);
 
    ap3.setXY(13, 111);
    ap3.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    ap3.setLinespacing(0);
    ap3.setAlpha(150);
    ap3.setTypedText(touchgfx::TypedText(T_SINGLEUSEID152));
    scrollableContainer1.add(ap3);
 
    ap2.setXY(13, 59);
    ap2.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    ap2.setLinespacing(0);
    ap2.setAlpha(150);
    ap2.setTypedText(touchgfx::TypedText(T_SINGLEUSEID151));
    scrollableContainer1.add(ap2);
 
    ap1.setXY(13, 8);
    ap1.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    ap1.setLinespacing(0);
    ap1.setAlpha(150);
    ap1.setTypedText(touchgfx::TypedText(T_SINGLEUSEID150));
    scrollableContainer1.add(ap1);
 
    buttonWithLabel1.setXY(600, 397);
    buttonWithLabel1.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_ID), touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_PRESSED_ID));
    buttonWithLabel1.setLabelText(touchgfx::TypedText(T_SINGLEUSEID156));
    buttonWithLabel1.setLabelColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    buttonWithLabel1.setLabelColorPressed(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    buttonWithLabel1.setAction(buttonCallback);
 
    add(box1);
    add(animatedImage1);
    add(textArea1);
    add(textArea2);
    add(textArea3);
    add(ap_available);
    add(scrollableContainer1);
    add(buttonWithLabel1);
}
 
void startupViewBase::setupScreen()
{
 
}
 
void startupViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
    if (&src == &buttonWithLabel1)
    {
        //Interaction1
        //When buttonWithLabel1 clicked call virtual function
        //Call function1
        function1();
    }
}

i get this error:

Error	1	error LNK2019: unresolved external symbol "public: void __thiscall startupViewBase::textareaClickHandler(class touchgfx::TextArea const &,class touchgfx::ClickEvent const &)" (?textareaClickHandler@startupViewBase@@QAEXABVTextArea@touchgfx@@ABVClickEvent@3@@Z) referenced in function "public: __thiscall startupViewBase::startupViewBase(void)" (??0startupViewBase@@QAE@XZ)

how to resolve it?

1 REPLY 1
Romain DIELEMAN
ST Employee

Hi,

I'm having a look but for now I just want to point out that you should try not to work in the ViewBase files in general, as it gets overwritten whenever you generate from TouchGFX Designer. What you are trying to do can be done in the View.cpp and hpp. It is a bad habit that can simplify the work at first but can also turn horribly wrong by mistake.

/Romain