cancel
Showing results for 
Search instead for 
Did you mean: 

TextArea and Keyboard.

slavaglow
Associate II

1) How can I make the TextArea widget clickable and handle the PRESSED and RELEASED events separately?

2) How to create a keyboard? When the TextArea is clicked, the keyboard appears, numeric data is entered, and it closes. Is there an example of a project using a keyboard?

 

1 REPLY 1
JTP1
Lead

Hello

You can get press and release events if you add Click- callback .

First set item 'clickListener' selected from Mixins- selections from your textArea.

JTP1_0-1705685140624.png

then add callback funtion definitions to your View.hpp

class Screen1View : public Screen1ViewBase { public: Screen1View(); virtual ~Screen1View() {} virtual void setupScreen(); virtual void tearDownScreen(); // add this: void textAreaClickHandler(const TextArea& b, const ClickEvent& e); protected: // and this: Callback<Screen1View, const TextArea&, const ClickEvent&> textAreaClickedCallback; };

then modify your View.cpp:

#include <gui/screen1_screen/Screen1View.hpp> // Add this if use touchgfx_printf- in simulator #include <touchgfx/Utils.hpp> // in constuctor, bind this view object to function which handles the event: Screen1View::Screen1View(): textAreaClickedCallback(this, &Screen1View::textAreaClickHandler) { } void Screen1View::setupScreen() { Screen1ViewBase::setupScreen(); //set the textArea1 action to exucute callback textArea1.setClickAction(textAreaClickedCallback); } void Screen1View::tearDownScreen() { Screen1ViewBase::tearDownScreen(); } //Add this clickHandler: void Screen1View::textAreaClickHandler(const TextArea& b, const ClickEvent& evt) { if (&b == &textArea1) { switch(evt.getType()) { case ClickEvent::PRESSED: touchgfx_printf("Pressed textArea1 \r\n"); break; case ClickEvent::RELEASED: touchgfx_printf("Released textArea1 \r\n"); break; //default: case ClickEvent::CANCEL: touchgfx_printf("Cancel textArea1 \r\n"); break; } } }
View more

This example is tested with simulator in versio 4.21.4.

you can get more detailed info here

https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/mixins

also here is same issue with flexButton

https://community.st.com/t5/stm32-mcus-touch-gfx-and-gui/how-do-i-trigger-a-new-virtual-function-when-a-touch-button/m-p/52581

2) There is example keyboard in this thread

https://community.st.com/t5/stm32-mcus-touch-gfx-and-gui/share-your-custom-widgets/td-p/67889

Hope this helps for forward

Br JTP