2020-02-29 09:48 AM
Hello! I create CustomContainer1, added to it textArea1 with wildcard buffer
I added CustomContainer1 to ScrollList2 and compiled project
I added button1 and want to change item №2 in CustomContainer1 by clicking button1
I added Iteraction to button1 - clicking is calling ChangeItemName() function.
In CustomContainer1.cpp :
void CustomContainer1::SetItemName(uint16_t data)
{
Unicode::snprintf(textArea1Buffer, 20, "%d", data);
textArea1.setWildcard(textArea1Buffer);
textArea1.resizeToCurrentText();
textArea1.invalidate();
}
In Screen1View.cpp:
void Screen1View::scrollList2UpdateItem(CustomContainer1& item, int16_t itemIndex)
{
uint16_t item_name_value;
item_name_value=itemIndex;
item.SetItemName(item_name_value);
}
void Screen1View::ChangeItemName(uint16_t number)
{
??????????????????????????????
}
What I have to add to ChangeItemName() if I want to change some Item of ScrollList ?
CustomContainer1.SetItemName(1); - error
2020-03-01 01:47 AM
I found solution!!
(*(CustomContainer1*)scrollList1ListItems.getDrawable(ItemNumber)).SetItemName(ItemName);
2020-03-01 03:30 AM
Still have problem
uint8_t str[] = "FileName";
Unicode::snprintf(textArea1Buffer, 20, "%s", str);
textArea1.setWildcard(textArea1Buffer);
textArea1.resizeToCurrentText();
Can't write any text.
uint8_t str[] = "FileName";
uint16_t data;
Unicode::snprintf(textArea1Buffer, 20, "%d", data);
textArea1.setWildcard(textArea1Buffer);
textArea1.resizeToCurrentText();
output digits.
How to write text?
2020-03-01 05:39 AM
Solved!
I didn't set wildcard range.
But.... still have problem
Unicode::snprintf(textArea1Buffer, 20, "%s","RB
prints "B".
Unicode::snprintf(textArea1Buffer, 20, "%s","RBJ");
prints "?J?"
Only last character and "?"
Why?
2020-03-01 05:56 AM
Hi,
try this:
const char str[] = "FileName";
Unicode::strncpy(textArea1Buffer, str, 20);
textArea1.setWildcard(textArea1Buffer);
textArea1.resizeToCurrentText();
Best regards,
Peter
2020-03-01 06:07 AM
Thanks!!!
Your code works!!!!
2020-03-01 06:37 AM
Hi,
your code doesn't work because %s needs a zero-terminated UnicodeChar list, but you passed a const char ("RBJ").
You have to copy your string to a UnicodeChar list and pass your UnicodeChar buffer to snprintf:
Unicode::UnicodeChar buffer[20];
const char str[] = "RBJ";
Unicode::strncpy(buffer, str, 20);
Unicode::snprintf(textArea1Buffer, 20, "%s", buffer);
textArea1.resizeToCurrentText();
2020-03-01 06:52 AM
Good! It works!!!
Thanks!