cancel
Showing results for 
Search instead for 
Did you mean: 

Keyboard widget and Custom Keyboard example - how to get scrollable text in the display field?

GHeller
Associate III

Hello.

I am in need of inputting large strings of text (larger than the width of the screen) using keyboard. I have managed to get a working keyboard, but after increasing the buffer size, the text is being cut off after it leaves the widget area.

I want to be able to scroll the written text left and right, or maybe even up and down. This would require me to somehow get a Scrollable Container as a parent for the text area, or rather the Rect textAreaPosition (which is part of Layout structure), which the text is being drawn on.

I have managed to increase the size of drawn text dynamically by calling setLayout(&layout) after changing the size of textAreaPosition, which means that Scrollable Container could work (although I wonder how will calling this method so fast impact the performance). The question is how to add Scrollable Container as a parent of Rect textAreaPosition, without changing the provided Keyboard widget code? Is it doable? Maybe there is an easy way of doing what I want? Any help appreciated.

0693W00000KbabrQAB.png

1 ACCEPTED SOLUTION

Accepted Solutions
Osman SOYKURT
ST Employee

Hello GHell.1,

The example we provide in TouchGFX Designer is quite old. We have planned to recode it using the widgets so that users can easily modify things within TouchGFX Designer.

To answer your question, no it's not possible without changing the code, and yes it's doable. My suggestion to you would be to try to instance a scrollable container and add your text area to it like this

touchgfx::ScrollableContainer myScrollableContainer;
    touchgfx::TextArea myTextArea;
myScrollableContainer.add(myTextArea);

then you can play with ScrollableContainer API :)

myScrollableContainer.enableHorizontalScroll(true);

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX

View solution in original post

4 REPLIES 4
Osman SOYKURT
ST Employee

Hello GHell.1,

The example we provide in TouchGFX Designer is quite old. We have planned to recode it using the widgets so that users can easily modify things within TouchGFX Designer.

To answer your question, no it's not possible without changing the code, and yes it's doable. My suggestion to you would be to try to instance a scrollable container and add your text area to it like this

touchgfx::ScrollableContainer myScrollableContainer;
    touchgfx::TextArea myTextArea;
myScrollableContainer.add(myTextArea);

then you can play with ScrollableContainer API :)

myScrollableContainer.enableHorizontalScroll(true);

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX

Thank you for response!

The solution turned out to be much simpler than I had originally thought...

I don't know why it didn't cross my mind earlier.

Anyway, I managed to make this work as you suggested.

I extended the CustomKeyboard class with a scrollable container, a text area to put my new scrollable text into, and an image to hide the originally displayed text.

0693W00000KblVPQAZ.png

Great job ! :)

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX
GHeller
Associate III

Sorry to necro but I've been asked for the code so here you go.