Skip to main content
hjh
Associate III
December 2, 2021
Solved

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

  • December 2, 2021
  • 3 replies
  • 1814 views

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

This topic has been closed for replies.
Best answer by Peter BENSCH

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

3 replies

Peter BENSCH
Peter BENSCHBest answer
Technical Moderator
December 3, 2021

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
hjhAuthor
Associate III
December 3, 2021

Thanks ....helped me a lot

Hjalmar

Peter BENSCH
Technical Moderator
December 6, 2021

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
hjhAuthor
Associate III
December 6, 2021

hi thanks did that