2020-12-28 12:58 PM
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?
Solved! Go to Solution.
2020-12-28 08:25 PM
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
2020-12-28 04:45 PM
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.
2020-12-28 08:15 PM
"89->891 the 1 is from the previous "101" number " - I guessed it.
" twice" - where and where in code? I called SetWildcard only once.
2020-12-28 08:25 PM
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
2020-12-28 08:36 PM
"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.
2020-12-28 08:58 PM
Thanks! I guessed, how to do it. All works fine!
2021-01-04 11:25 PM
Hello EEuge,
When your question is answered, please close this topic by choosing Select as Best.
/Alexandre