cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with text wildcard

EEuge
Senior

Hello!

I have textArea with wildcard, which is updated by Slider moving

void OPTIONS_SCREENView::R_Slider_MOVED(int value)
{
 
RGB_LED_Sample_box.setColor(touchgfx::Color::getColorFrom24BitRGB(R_Slider.getValue(), G_Slider.getValue(), B_Slider.getValue()));
RGB_LED_Sample_box.invalidate();
	
Unicode::snprintf(R_Value_textBuffer, 20, "%d", value);
R_Value_text.setWildcard(R_Value_textBuffer);
R_Value_text.resizeToCurrentText();  
R_Value_text.invalidate();
}

When I set values from 0 to 255, everything is fine. When reduce from 255 to 0 - problem: if the number is less than 100, then a 3 digit incorrect number, 1 and 2 - correct two-digit number, if less than 10 during the 2nd and 3rd digits of the wrong number, the first correct one digit number.

values in variable "value" - are always correct.

For example:

255->255

101->101

89->891

78->781

11->111

9->911

What's wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
Bob Bailey
Senior
	
Unicode::snprintf(R_Value_textBuffer, 20, "%d", value);
R_Value_text.invalidate();                                               // invalidate the old size of the text
R_Value_text.setWildcard(R_Value_textBuffer);
R_Value_text.resizeToCurrentText();  
R_Value_text.invalidate();

this will do it I think. or create the textarea large enough for the biggest number and dont resize it

View solution in original post

6 REPLIES 6
Bob Bailey
Senior

you need to invalidate twice. first to remove the old number, then to make the new number get drawn. 89->891 the 1 is from the previous "101" number.

"89->891 the 1 is from the previous "101" number " - I guessed it.

" twice" - where and where in code? I called SetWildcard only once.

Bob Bailey
Senior
	
Unicode::snprintf(R_Value_textBuffer, 20, "%d", value);
R_Value_text.invalidate();                                               // invalidate the old size of the text
R_Value_text.setWildcard(R_Value_textBuffer);
R_Value_text.resizeToCurrentText();  
R_Value_text.invalidate();

this will do it I think. or create the textarea large enough for the biggest number and dont resize it

"this will do it I think" - Works! Thanks!

"or create the textarea large enough for the biggest number a" - how to do it? Where can I set size?

I want to use second of your variants, because if I resize - alignment not works.

Thanks! I guessed, how to do it. All works fine!

Alexandre RENOUX
Principal

Hello EEuge,

When your question is answered, please close this topic by choosing Select as Best.

/Alexandre