2019-06-26 04:15 AM
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;
}
2019-06-28 05:12 AM
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
2019-06-28 06:00 AM
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.
2019-06-30 01:31 PM
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
2019-06-30 11:33 PM
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
2019-07-01 05:48 AM
Hi,
Yes, the setWildcard() method tells the textarea which buffer it should use when it renders its text. Otherwise the rendering mechanism does not know how to render the text - You could say that it should enforce a wildcard buffer, maybe, because not having a wildcard at all would not make sense.
text.invalidate()
.. has an effect, depending on how you use it. It's often used in conjunction with wildcards (as far as text areas are concerned). Imagine that you Unicode::snprintf() your new temperature value into your wildcard buffer. The text area would not know about this update unless you "invalidate" and tell it to redraw.
/Martin