This creates a nice semi-transparent background which also prevents the user from touching any elements it overshadows. However, this means redrawing the entire screen instead of the portion of the screen where the messagebox should be displayed.
Creating a background myself and just setting the opacity to 0 sadly does not work, it will still attempt to draw the (technically invisible) background.
What other options do I have? Maybe a flag I overlooked…
after trying some more options I eventually decided to just disable all inputs “manually” by recursively looping through the background’s (screen obj) children and disabling the CLICKABLE flag for each child. It turns out that this is the only flag that needs to be disabled, disabling and re-enabling other flags afterwards lead to unexpected results.
After disabling all inputs I add the messagebox as a child of the background: all inputs here will still be enabled normally because it is added after disabling the other children’s input.
Hope this post helps others also trying to do the same thing! I mainly wanted to avoid the semi-transparent background because redrawing the whole screen takes too much time.
Hello Tinus,
I used “Window” widget and the icon in background still touchable, so we have the same problem.
I thought about your approach, but I found a new problem:
Some object was untouchable default like “image”, but your function set all children touchable.
I have an idea, why not create popup window on “lv_layer_sys()”.
lv_obj_add_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); Can disable touch lv_layer_top().
Hello, if you want to use a window as a popup, I would recommend creating a custom msgbox object and following the steps I did, it works well. lv_layer_sys() just returns the current active screen of the default display, which means you are drawing the window next to existing objects on that screen instead of on top of it.
Yes, I create window (message box) at the Top-Layer now and it work fine.
But I found a new problem, if more than one window (message box) created at Top-Layer, it would still suffers from front and back click response issues.
Glad to hear it works. Perhaps you could disable input on the previously created messagebox when you make a new one? If I’m correct, everything below lv_layer_top will still be unclickable.
The layer_top can be used by the user to create some content visible everywhere. For example, a menu bar, a pop-up, etc. If the click attribute is enabled, then layer_top will absorb all user click and acts as a modal.
Popup windows nesting is only for discussion, it should be avoided in the application, after all, the MCU is not a computer.