cancel
Showing results for 
Search instead for 
Did you mean: 

TOUCHGFX ... Add char to textarea ... How to add a char to the end of the text displayed in a textarea.

hjh
Associate III

I do

void Screen1View::updateAsciiInView(char* CwChar)

{

// add to txtbuffer

Unicode::strncpy(textAreaAsciiBuffer, CwChar, 1);

textAreaAscii.invalidate();

}

and that works fine ...my char i s displayed in the first position.

But i need to add it to the end so need something like

void Screen1View::updateAsciiInView(char* CwChar)

{

get the current textbuffer

add to the end of the buffer

Unicode::strncpy(textAreaAsciiBuffer, buffer, buffer length);

textAreaAscii.invalidate();

}

But how to do that ...

THANKS ;o)

Hjalmar

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

You could define a variable, e.g. bufferPosition and store the length of the recent buffer in it, as it is done in Keyboard.cpp/Keyboard.hpp (part of the widgets):

void Keyboard::setBuffer(Unicode::UnicodeChar* newBuffer, uint16_t newBufferSize)
{
    buffer = newBuffer;
    bufferSize = newBufferSize;
 
    enteredText.setWildcard(buffer);
 
    // Place cursor at end of string if we already have something
    // in the edit buffer.
    bufferPosition = Unicode::strlen(buffer);
}

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
Peter BENSCH
ST Employee

You could define a variable, e.g. bufferPosition and store the length of the recent buffer in it, as it is done in Keyboard.cpp/Keyboard.hpp (part of the widgets):

void Keyboard::setBuffer(Unicode::UnicodeChar* newBuffer, uint16_t newBufferSize)
{
    buffer = newBuffer;
    bufferSize = newBufferSize;
 
    enteredText.setWildcard(buffer);
 
    // Place cursor at end of string if we already have something
    // in the edit buffer.
    bufferPosition = Unicode::strlen(buffer);
}

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
hjh
Associate III

Thanks ....helped me a lot

Hjalmar

Great!

If the problem is resolved, please mark this topic as answered by selecting Select as best. This will help other users find that answer faster.

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
hjh
Associate III

hi thanks did that