当前位置:网站首页>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
边栏推荐
- Golang 语言实现TCP UDP通信
- About the operation of unit file reading (I)
- Daily CISSP certification common mistakes (April 15, 2022)
- SQL中函数 decode()与 replace()的用法
- Résolution: cnpm: impossible de charger le fichier... Cnpm. PS1 parce que l'exécution de scripts est désactivée sur ce système
- Solution to Chinese garbled code after reg file is imported into the registry
- Machine learning theory (7): kernel function kernels -- a way to help SVM realize nonlinear decision boundary
- ESP32 LVGL8. 1 - calendar (calendar 25)
- ESP32 LVGL8. 1 - BTN button (BTN 15)
- listener.log
猜你喜欢
logstash 7. There is a time problem in X. the difference between @ timestamp and local time is 8 hours
listener. log
Analysez l'objet promise avec le noyau dur (Connaissez - vous les sept API communes obligatoires et les sept questions clés?)
kettle庖丁解牛第17篇之文本文件输出
Machine learning theory (8): model integration ensemble learning
实战业务优化方案总结---主目录---持续更新
Summary of actual business optimization scheme - main directory - continuous update
WiFi ap6212 driver transplantation and debugging analysis technical notes
[mathematical modeling] - analytic hierarchy process (AHP)
机器学习理论之(8):模型集成 Ensemble Learning
随机推荐
Database computer experiment 4 (data integrity and stored procedure)
ESP32 LVGL8. 1 - event (event 17)
数据库上机实验四(数据完整性与存储过程)
Teach you to quickly rename folder names in a few simple steps
Actual combat of Nacos as service configuration center
22年字节跳动飞书人力套件三面面经
iptables初探
Daily CISSP certification common mistakes (April 18, 2022)
Nacos集群搭建和mysql持久化配置
QT tablewidget insert qcombobox drop-down box
Kettle paoding jieniu Chapter 17 text file output
解决:cnpm : 無法加載文件 ...\cnpm.ps1,因為在此系統上禁止運行脚本
Quantexa CDI(场景决策智能)Syneo平台介绍
QT notes on qmap container freeing memory
iptables -L执行缓慢
Machine learning theory (8): model integration ensemble learning
特征选择feature_selection--SelectKBest
Iptables - L executes slowly
ctfshow-web362(SSTI)
Implementation of TCP UDP communication with golang language