Git Product home page Git Product logo

Comments (9)

kisvegabor avatar kisvegabor commented on May 16, 2024

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.

BenQoo avatar BenQoo commented on May 16, 2024

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

text_area

from lvgl.

BenQoo avatar BenQoo commented on May 16, 2024

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.

kisvegabor avatar kisvegabor commented on May 16, 2024

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.

BenQoo avatar BenQoo commented on May 16, 2024

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.

kisvegabor avatar kisvegabor commented on May 16, 2024

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.

BenQoo avatar BenQoo commented on May 16, 2024

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.

kisvegabor avatar kisvegabor commented on May 16, 2024

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.

kisvegabor avatar kisvegabor commented on May 16, 2024

Fixed in v5.0.0

from lvgl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.