cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX 4.24 and textfield in container

amigafan
Associate II

HI, could you come up with an example of how to access a textfield from a custom container in the Main screen?

Thanks in advance.

3 REPLIES 3
tdecker2
Associate II

You have to add a public method to your CustomContainer-class, for example

 

void setText(Unicode::Unichar * text);

And copy the text to your textfield wildcard array. Then you can call this method from your Main screen view class.

Another way could be exposing the TextArea object to the outside world by adding a method like this:

TextArea & getTextArea() { return myTextArea;}

 

 

HI, thanks for the quick replay, but a have 5 identical containers in Mainscreen and then the textfields will have the same ID, and I want to access them individually.

If you have 5 instances of your CustomContainer on your View, you can give every instance a different text:

myContainer1.getTextArea.setTypedText(touchgfx::TypedText(T_TEXT1));
myContainer2.getTextArea.setTypedText(touchgfx::TypedText(T_TEXT2));
myContainer3.getTextArea.setTypedText(touchgfx::TypedText(T_TEXT3));
myContainer4.getTextArea.setTypedText(touchgfx::TypedText(T_TEXT4));
myContainer5.getTextArea.setTypedText(touchgfx::TypedText(T_TEXT5));