2019-02-15 02:26 AM
Hello,
I'm trying to retrieve the text string of a textarea widget with the function getTypedText() but I get an access error. No wildcards are used in the textArea2, the propery "Text"is just filled in with a short text in the designer.
2019-02-15 08:30 PM
Hi. Can you try with
getText()
instead of
getTypedText()
and post your update?
2019-02-17 11:28 PM
Hey. getText() is not a function of the class touchgfx::TouchArea() ;)
2019-02-18 01:09 AM
Hi guys,
Allow me to clear up a few things. The TypedText class is a container for both Typography and Text, so you cannot use it directly in a printf statement. A TypedText does however have the getText() method.
Even then, Texts in touchgfx are 16-bit unicodes and cannot be used directly either.
typedef uint16_t UnicodeChar;
A TypedText contains a pointer to a UnicodeChar array.
Here's a small example i wrote that prints TypedText texts (Unicode::UnicodeChar*) through a small conversion method. You can also use this directly on the Unicode buffers for TextAreas with Wildcard.
Screen1.hpp:
#ifndef SCREEN1_VIEW_HPP
#define SCREEN1_VIEW_HPP
#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include <gui/screen1_screen/Screen1Presenter.hpp>
class Screen1View : public Screen1ViewBase
{
public:
Screen1View();
virtual ~Screen1View() {}
virtual void setupScreen();
virtual void tearDownScreen();
void convertUnicodeToAscii(const uint16_t* in, uint8_t* out);
protected:
};
Screen1.cpp:
Screen1View::Screen1View()
{
uint8_t output[20];
const uint16_t* text = textArea1.getTypedText().getText();
convertUnicodeToAscii(text, output);
touchgfx_printf("Text: %s", output);
}
void Screen1View::convertUnicodeToAscii(const uint16_t* in, uint8_t* out)
{
while(*in != 0){
*out++ = (uint8_t)*in++;
}
*out = 0;
}
Output:
Hope that helps.
Best regards,
Martin
2019-02-18 05:57 AM
@Martin KJELDSEN , thanks for the clarification.
Hey, @GMeur , you are welcome for the assistance :)
2020-02-02 11:48 AM
Hi Mr Martin KJELDSEN
above code work fine. but when add wildcard text, output show unknown character.
Please guide me to use this function "const Unicode::UnicodeChar* getWildcard()const"
touchgfx_printf("Text: *%s*", output );
Best regards