How to create msgbox with background unclickable?

Description

How to create msgbox with background unclickable?

What MCU/Processor/Board and compiler are you using?

STM32F7

What LVGL version are you using?

v7.7

What do you want to achieve?

When poping a msgbox , make all the background obj unclickable and add some black opa . When press the btn on msgbox, quit msgbox and recover all the background.

What have you tried so far?

lv_obj_set_click(lv_disp_get_layer_top(NULL), true ); and create the msgbox on it . right?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Is this what you’re looking for? https://docs.lvgl.io/latest/en/html/widgets/msgbox.html#modal

1 Like

Hi, embeddedt,
Many Thanks!

  1. I am running with msgbox and want to make the other obj on the screen unclickable, except the msgbox btn. Set lv_obj_set_click(lv_disp_get_layer_top(NULL), true ); and create the msgbox on it . right?
  2. I got know the different between lv_obj_set_style_local_bg_color and lv_style_set_bg_color, but when should I use the former?
  3. Is there any tool to monitor the runtime memory allocation? How is the memory cost and the speed in v7.7 compared to the v6.0?

Merry Christmas!

Merry Christmas!

  1. I think that method also works.
  2. The former is better to use when overriding style properties for one object. If you plan to override the same style property on many objects, use the latter.
  3. You can use lv_mem_monitor like the PC simulator does. I am not sure of the exact statistics on memory consumption. v7’s performance has regressed slightly compared to v6, however the difference can be worked around as long as you have sufficient RAM available. v8 is expected to bring performance improvements.
1 Like

Hi, embeddedt,
Many Thanks!

  1. You means there have another easy way to make the background of the msgbox unclickable? Could you give me some advice on detail ?
  2. Can I adjust some letter space in a label? For example, the label β€œ123.456.789” , I would fix the letter width and let the β€œ.” to take the narrow space. How to implement? Could you give me some advice.

Merry Christmas & Best Regards,

  1. Please take a look at the example I linked above; it contains a full implementation.
  2. This probably belongs in its own post, but I think the simplest approach is to use FontForge and edit your font to reduce the spacing for a dot.
1 Like

Hi, embeddedt,
Many Thanks!

  1. In the default font,the letter width is a varible , so I set it to a fix width. Thus the β€œ.” will take a wider space than in the font lib. You means to create new font insdead of the default ? I will try.
  2. By monitor the mem, I found the used_cnt and max_used is continuous increasing and the refresh cycle will become slower and slower. The code is updated from v6.0 and work fine in that case. There have create a chart and some btn with label on it in the initial and just update the chart series and some other label in the main loop. How to detect the bug? Would like to have your advice!

Best Regards,

Please try with the latest master branch first; we fixed a memory leak there which could be your issue.

1 Like

Hi, embeddedt,
Many Thanks!
Had just tried the v7.90 dev master branch, the same mem issue occured. The used_cnt and max_used are growing from the 0x5BA and 0x10240 at the beginning to 0x3CD2 and 0x39A74 after running for 20 mins.
Could you give me some advice on the detail for debug?

Best Regards,

There are two approaches that can be used here.

The first is to try cutting out parts of your program, not updating certain widgets, etc. until you find what is causing the problem. It looks like either you are or LVGL is allocating memory and not freeing it.

The other option is to attach a debugger while the program is running and find what is calling lv_mem_alloc. You may trace it to a point where there is no corresponding call to lv_mem_free.

1 Like

Hi, embeddedt,
Many Thanks!

Found out the issue,that I had used lv_style_set_line_color in my design func , which call the mem allocation.
BTW, why we just left one default theme in the v7.9 and more than one in the v6.0?

Best Regards,

We reduced the theme selection to simplify development. There are now only two official themes: material and mono.

1 Like