当前位置:网站首页>ESP32 LVGL8. 1 - msgbox message box (msgbox 28)
ESP32 LVGL8. 1 - msgbox message box (msgbox 28)
2022-04-23 18:40:00 【Please call me Xiao Peng】
Tips : This blog serves as a learning note , If there are mistakes, I hope to correct them
List of articles
One 、textarea brief introduction
1.1 summary Overview
“ news ” Box acts as a pop-up window . They consist of a background container 、 A title 、 An optional close button and an optional button constructed from text . The text will be automatically divided into multiple lines , The height will be automatically set to include text and buttons . Message boxes can be modal ( Block the rest of the screen from clicking ), It can also be non modal .
1.2 Part and style Parts and Styles
The message box is built by other widgets , So you can check the documentation of these widgets for details .
• background :lv_obj
• close button :lv_btn
• Title and text :lv_label
• Button :lv_btnmatrix
1.3 Use Usage
1.3.1 Create a message box Create a message box
Lv_msgbox_create (parent, title, txt, btn_txts[], add_close_btn) Create a message box .
If parent by NULL, The message box will be modal .Title and TXT Is a string of title and text .btn_txts []
Is an array with button text . for example const char * btn_txts[] = {“Ok”, “Cancel”, NULL}.
Add_colse_btn It can be for true or false To add / Do not add close button .
1.3.2 Get parts Get the parts
The building blocks of the message box can be obtained through the following functions :
lv_obj_t * lv_msgbox_get_title(lv_obj_t * mbox);
lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * mbox);
lv_obj_t * lv_msgbox_get_text(lv_obj_t * mbox);
lv_obj_t * lv_msgbox_get_btns(lv_obj_t * mbox);
1.3.3 Close the message box Close the message box
Lv_msgbox_close (msgbox) close ( Delete ) Message box .
1.4 event Events
If one of them is clicked ,LV_EVENT_VALUE_CHANGED Will be sent by the button . Enabled... On the button LV_OBJ_FLAG_EVENT_BUBBLE, So you can add events to the message box itself . In the event handler ,lv_event_get_target(e) Will return Button Matrix and lv_event_get_current_target(e) The message box is returned .
lv_msgbox_get_active_btn(msgbox) and lv_msgbox_get_active_btn_text(msgbox) Click buttons that can be used to get indexes and text .
1.5 Key Keys
The key has an effect on the close button and button matrix . if necessary , You can manually add them to the Group .
Two 、msgbox API
/******************
* Create a message box object
* @param Parent pointer or NULL Create a full screen modal message box
* @param title The title of the message box
* @param TXT The text of the message box
* @param btn_txts The button acts as a to “” An array of text at the end of the element . for example :{
"btn1", "btn2", ""}
* @param add_close_btn true: Add a close button
* @return Pointer to the message box object
*******************/
lv_obj_t * lv_msgbox_create(Lv_obj_t * parent, const char * title, const char * txt, const char * btn_txts[],bool add_close_btn);
// Get the title of the message box
lv_obj_t * lv_msgbox_get_title(Lv_obj_t * obj);
// Get the close button of the message box
lv_obj_t * lv_msgbox_get_close_btn(Lv_obj_t * obj);
// Get the text content of the message box
lv_obj_t * lv_msgbox_get_text(Lv_obj_t * obj);
// Get the directory of the message box
lv_obj_t * lv_msgbox_get_content(Lv_obj_t * obj);
// Get the button of the message box
lv_obj_t * lv_msgbox_get_btns(Lv_obj_t * obj);
/**
* Gets the index of the selected button
* @param mbox Message box object
* @ Returns the index of the button (LV_BTNMATRIX_BTN_NONE: If not set )
*/
uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox);
// Get active key text
const char * lv_msgbox_get_active_btn_text(lv_obj_t * mbox);
// Close the message box
void lv_msgbox_close(lv_obj_t * mbox);
// Close the message box
void lv_msgbox_close_async(lv_obj_t * mbox);
3、 ... and 、 Example
3.1 Example to achieve digital key input
static void event_cb(lv_event_t * e)
{
lv_obj_t * obj = lv_event_get_current_target(e);
LV_LOG_USER("Button %s clicked", lv_msgbox_get_active_btn_text(obj));
}
void lv_example_msgbox_1(void)
{
static const char * btns[] ={
"Apply", "Close", ""};// Create button character
lv_obj_t * mbox1 = lv_msgbox_create(NULL, "Hello", "This is a message box with two buttons.", btns, true);
lv_obj_add_event_cb(mbox1, event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_center(mbox1);
}

版权声明
本文为[Please call me Xiao Peng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210609449995.html
边栏推荐
- 程序员如何快速开发高质量的代码?
- 昇腾 AI 开发者创享日全国巡回首站在西安成功举行
- CANopen STM32 transplantation
- Daily CISSP certification common mistakes (April 19, 2022)
- Analysez l'objet promise avec le noyau dur (Connaissez - vous les sept API communes obligatoires et les sept questions clés?)
- 七、DOM(下) - 章节课后练习题及答案
- Teach you to quickly rename folder names in a few simple steps
- QT add external font ttf
- Connection mode of QT signal and slot connect() and the return value of emit
- 回路-通路
猜你喜欢

使用晨曦记账本,分析某个时间段每个账户收支结余

机器学习实战 -朴素贝叶斯

Ctfshow - web362 (ssti)

STM32: LCD display

ESP32 LVGL8. 1 - arc (arc 19)

Machine learning theory (7): kernel function kernels -- a way to help SVM realize nonlinear decision boundary

In win10 system, all programs run as administrator by default

kettle庖丁解牛第17篇之文本文件输出
![[mathematical modeling] - analytic hierarchy process (AHP)](/img/ff/2350c9604a03fff6a6a751aa3cfa3b.png)
[mathematical modeling] - analytic hierarchy process (AHP)

MVVM模型
随机推荐
Ctfshow - web362 (ssti)
QT error: no matching member function for call to ‘connect‘
Nacos作为服务配置中心实战
深入理解 Golang 中的 new 和 make 是什么, 差异在哪?
Machine learning theory (8): model integration ensemble learning
Nacos as service registry
使用 bitnami/postgresql-repmgr 镜像快速设置 PostgreSQL HA
CISSP certified daily knowledge points (April 11, 2022)
ctfshow-web361(SSTI)
How to restore MySQL database after win10 system is reinstalled (mysql-8.0.26-winx64. Zip)
数据库上机实验四(数据完整性与存储过程)
iptables -L执行缓慢
Jeecg boot microservice architecture
Halo 开源项目学习(七):缓存机制
After CANopen starts PDO timing transmission, the heartbeat frame time is wrong, PDO is delayed, and CANopen time axis is disordered
视频边框背景如何虚化,简单操作几步实现
listener. log
Database computer experiment 4 (data integrity and stored procedure)
Deeply understand what new and make in golang are and what are the differences?
Configure iptables