当前位置:网站首页>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
边栏推荐
- Keil RVMDK compiled data type
- Spark performance optimization guide
- Mysqldump backup database
- CISSP certified daily knowledge points (April 14, 2022)
- Use of regular expressions in QT
- Druid SQL和Security在美团点评的实践
- Ionic instruction set order from creation to packaging
- 机器学习理论之(7):核函数 Kernels —— 一种帮助 SVM 实现非线性化决策边界的方式
- Creation and use of QT dynamic link library
- QT add external font ttf
猜你喜欢
【科普】CRC校验(一)什么是CRC校验?
How to restore MySQL database after win10 system is reinstalled (mysql-8.0.26-winx64. Zip)
昇腾 AI 开发者创享日全国巡回首站在西安成功举行
七、DOM(下) - 章节课后练习题及答案
ctfshow-web361(SSTI)
使用 bitnami/postgresql-repmgr 镜像快速设置 PostgreSQL HA
Use bitnami / PostgreSQL repmgr image to quickly set up PostgreSQL ha
函数递归以及趣味问题的解决
Machine learning theory (7): kernel function kernels -- a way to help SVM realize nonlinear decision boundary
Creation and use of QT dynamic link library
随机推荐
Daily network security certification test questions (April 15, 2022)
Use of regular expressions in QT
Solution to Chinese garbled code after reg file is imported into the registry
Use stm32cube MX / stm32cube ide to generate FatFs code and operate SPI flash
Serial port debugging tools cutecom and minicom
iptables初探
Sentinel service fusing practice (sentinel integration ribbon + openfeign + fallback)
ESP32 LVGL8. 1 - event (event 17)
ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)
数据库上机实验四(数据完整性与存储过程)
Custom prompt box MessageBox in QT
ESP32 LVGL8. 1 - checkbox (checkbox 23)
Hard core parsing promise object (do you know these seven common APIs and seven key questions?)
The first leg of the national tour of shengteng AI developer creation and enjoyment day was successfully held in Xi'an
Machine learning practice - naive Bayes
Halo 开源项目学习(七):缓存机制
ESP32 LVGL8. 1 - anim animation (anim 16)
CANopen usage method and main parameters of object dictionary
机器学习理论之(7):核函数 Kernels —— 一种帮助 SVM 实现非线性化决策边界的方式
Promote QT default control to custom control