Skip to main content
bitlischieber
Associate III
June 26, 2019
Question

TypedText is not replaced by the one in textBuffer

  • June 26, 2019
  • 5 replies
  • 1328 views

I am working on an Application where I am using a ScrollList which should serve as menu.

There is no touch so I control the behaviour by buttons.

Depended on the menu to show the content is predefined by text resources. However some content is dynamic such as a file list which I intent to display.

If I set the TypedText it is displayed correctly, but if I afterwards like to change the entry a a dynamic text, the TypedText is not cleared.

 virtual void scrollListMenuUpdateItem(lstEntry& item, int16_t itemIndex)
{
 :
 // sometime a predefined text is displayed
 item.setItemTypedText(T_MAIN_MENU_SETUP);
 :
 // in antoher case, a dynamic text should be displayed
 item.setItemText(fileList[itemIndex].c_str());
 :
 // force redraw
 item.invalidate();
}

How can I flush the old text of the list items?

Here are the implementations of the methods:

void setItemTypedText(TypedTextId typedTextId)
{
 text.setTypedText(TypedText(typedTextId));
}
 
void setItemText(const char* itemText)
{
 touchgfx::Unicode::strncpy(textBuffer, itemText, TEXT_SIZE);
 textBuffer[TEXT_SIZE-1] = 0;
}

This topic has been closed for replies.

5 replies

bitlischieber
Associate III
June 28, 2019

Also by using setWildcard(..) it does not update correctly:

void setItemText(const char* itemText)
 {
 	touchgfx::Unicode::strncpy(textBuffer, itemText, TEXT_SIZE);
 	text.setWildcard(textBuffer);
	text.resizeToCurrentText();
	text.invalidate();
}

Another question: Is it correct, that "invalidate()" for "text" (type TextAreaWithOneWildcard) and the ScrollList itself is not implemented?

Br. Raphael

bitlischieber
Associate III
June 28, 2019

Ok, this took me about 3 days: My menu item consists of a text field with only a wildcard.

In this case you have to use "setWildcard(..)" instead of "setTypedText(..)" to show a TypedText!

Therefore the issue was in my "setItemTypedText(TypedTextId typedTextId)" method.

Here the corrected version:

void setItemTypedText(TypedTextId typedTextId)
{
 text.setWildcard(TypedText(typedTextId).getText());
 text.resizeToCurrentText();
 text.invalidate();
}

If you use "setTypedText(..)" it seems you never gona to replace the text set.

Martin KJELDSEN
Principal III
June 30, 2019

Hi @bitlischieber​,

I've been traveling, so i haven't been able to keep up with the forum. Looks like you figured things out on your own? I'll take a closer look tomorrow.

/Martin

bitlischieber
Associate III
July 1, 2019

Hi @Martin KJELDSEN​ 

Thanks for your reply.

I think the issue was indeed, that I had a text field only with a wildcard text.

Apparently in this case you have to use "setWildcard()" instead of "setTypedText()" to display a defined typed text.

setTypedText() will work, but i was not able to overwrite the text again.

Another thing which I stumbled over during debugging:

text.invalidate();

Is it possible that this statement has no effect? I think there is just the overridable definition but no implementation of this method.

Should I implement this? And if yes, how.

Thanks and best regards

Raphael