Comments (9)
Hi,
maybe I wasn't clear in the documentation. The Text area is a Page too and the Label inherits its style.
For example:
static lv_style_t style;
lv_style_get(LV_STYLE_PRETTY, &style);
style.ccolor = COLOR_RED; //Red text
style.mcolor = COLOR_GREEN; //Green color on the top of Text area
lv_obj_t * ta_1 = lv_ta_create(lv_scr_act(), NULL);
lv_obj_set_style(ta_1, &style);
from lvgl.
Hi,
Thanks for your reply.
I tested the following example, but style.ccolor
not work on cursor and text.
The color of cursor and text is still in black.
static lv_style_t style;
lv_style_get(LV_STYLE_PRETTY, &style);
style.ccolor = COLOR_RED; //Red text & red cursor?
style.mcolor = COLOR_GREEN; //Green color on the top of Text area
style.line_width = 5 * LV_DOWNSCALE;
lv_obj_t * ta_1 = lv_ta_create(lv_scr_act(), NULL);
lv_obj_set_style(ta_1, &style);
lv_obj_refr_style(ta_1);
from lvgl.
I have tried and found some ways to change the text color.
- To set a additional style object to label
- To change
ccolor
on the parent object of `lv_ta.
For example:
static lv_style_t style;
lv_style_get(LV_STYLE_PRETTY, &style);
style.ccolor = COLOR_RED; // Red text
style.mcolor = COLOR_GREEN; // Green color on the top of Text area
style.line_width = 5 * LV_DOWNSCALE;
lv_obj_t * ta_1 = lv_ta_create(lv_scr_act(), NULL);
lv_obj_set_style(ta_1, &style);
/* create style for label */
static lv_style_t txt_style;
lv_style_get(LV_STYLE_PRETTY, &txt_style);
txt_style.ccolor = COLOR_YELLOW;
lv_obj_t * label = lv_ta_get_label(ta_1);
lv_obj_set_style(label, &txt_style);
I'm not sure whether the two usages are correct or not.
Because it will become failed if I append the following function calls at the end of code.
lv_obj_refr_style(ta_1);
or
lv_page_set_sb_mode(ta_1, LV_PAGE_SB_MODE_OFF);
from lvgl.
Sorry, I forget to say, already there is bugfix related to this. Please, check out lvgl and misc beta
.
Your work around is okay too, but "one style" setting will work too in beta.
I'm not sure whether the two usages are correct or not.
Because it will become failed if I append the following function calls at the end of code.
lv_obj_refr_style(ta_1);
or
lv_page_set_sb_mode(ta_1, LV_PAGE_SB_MODE_OFF);
What do you experience? lv_obj_refr_style(ta_1);
is not required because lv_obj_set_style()
do it as well.
from lvgl.
What do you experience? lv_obj_refr_style(ta_1); is not required because lv_obj_set_style() do it as well.
I misunderstood that lv_obj_set_style()
have to notify object the style is changed, so I added lv_obj_refr_style()
after it. Thanks for your explanation, I get it!
After testing on beta
branch, text portion is working fine now, the cursor width and color are not changed by ccolor
and line_width
.
from lvgl.
Great! :)
lv_obj_refr_style()
is required when your program is running and randomly you modify a style. The object need to be notified. However when you set a new style with lv_obj_set_style()
then the object will be refreshed to the new style automatically.
Thank you for reporting the issue. As it is working now I close it!
from lvgl.
sorry for my unclear.
On the cursor portion, I still can't control its width and color from lv_ta
's ccolor
and line_width
.
from lvgl.
Sorry, I misread it.
It was strange a behavior. I pushed a fix into beta
. Now it also uses the Text area style like the text do.
from lvgl.
Fixed in v5.0.0
from lvgl.
Related Issues (20)
- The Online Font Converter has a bug HOT 1
- Gridnav interaction with spinboxes or rollers HOT 13
- Separate lv_conf.h into 2 files: vendor specific + application specific HOT 3
- API retirement HOT 2
- Add a release script
- Add more gradient features HOT 16
- Support mouse wheel scroll and other gestures HOT 5
- Finalize SDL rendering HOT 1
- Implement an OpenGL ES based renderer HOT 5
- Add blurring support HOT 7
- Improve the span widget HOT 5
- Double and triple click support
- Support Lottie animation HOT 3
- Add SVG support HOT 8
- Planned new features
- Text & Image Shadow HOT 6
- Moving wallpaper test from benchmark wrong coordinates HOT 4
- Compiler error withing lv_label when LV_USE_BIDI is enabled HOT 2
- Separate font size from lv_font_t into individual style HOT 2
- slow dynamic image refresh HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lvgl.