cancel
Showing results for 
Search instead for 
Did you mean: 

Updating elements of ScrollList

EEuge
Senior

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

7 REPLIES 7
EEuge
Senior

I found solution!!

	(*(CustomContainer1*)scrollList1ListItems.getDrawable(ItemNumber)).SetItemName(ItemName);

EEuge
Senior

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?

EEuge
Senior

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?

PBull
Associate III

Hi,

try this:

	const char str[] = "FileName";
	Unicode::strncpy(textArea1Buffer, str, 20);
	textArea1.setWildcard(textArea1Buffer);
	textArea1.resizeToCurrentText();

Best regards,

Peter

Thanks!!!

Your code works!!!!

PBull
Associate III

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();

Good! It works!!!

Thanks!