当前位置:网站首页>LVGL 8.2 keyboard
LVGL 8.2 keyboard
2022-07-04 14:35:00 【Fairy sword love】
Event callback function processing
static void ta_event_cb(lv_event_t* e)
{
lv_event_code_t code = lv_event_get_code(e); // Get the event code generated by the object
lv_obj_t* ta = lv_event_get_target(e); // Get the object that generated the event
lv_obj_t* kb = lv_event_get_user_data(e); // Get the user data associated with the object
if (code == LV_EVENT_FOCUSED) {
// Focus event processing
lv_keyboard_set_textarea(kb, ta); // The text area is associated with the keyboard
lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN); // Clear the object hidden flag
LV_LOG_USER("%s","LV_EVENT_FOCUSED");
}
if (code == LV_EVENT_DEFOCUSED) {
// Lose focus event handling
lv_keyboard_set_textarea(kb, NULL); // Disassociate the text area from the keyboard
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN); // Add object hidden flag
LV_LOG_USER("%s","LV_EVENT_DEFOCUSED");
}
}
Create text area and keyboard
static void lv_example_keyboard_1(void)
{
/*Create a keyboard to use it with an of the text areas*/
lv_obj_t* kb = lv_keyboard_create(lv_scr_act()); // Create keyboard objects
/*Create a text area. The keyboard will write here*/
lv_obj_t* ta;
ta = lv_textarea_create(lv_scr_act()); // Create a text input box object
lv_obj_align(ta, LV_ALIGN_TOP_LEFT, 10, 10); // LV_ALIGN_TOP_LEFT Alignment
lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_ALL, kb); // Text input box object adds all events
lv_textarea_set_placeholder_text(ta, "Hello"); // Set placeholder character Hello
lv_obj_set_size(ta, 140, 80); // Set size
ta = lv_textarea_create(lv_scr_act()); // Create a text input box object
lv_obj_align(ta, LV_ALIGN_TOP_RIGHT, -10, 10); // LV_ALIGN_TOP_RIGHT Alignment
lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_ALL, kb); // Text input box object adds all events
lv_obj_set_size(ta, 140, 80); // Set size
lv_keyboard_set_textarea(kb, ta); // The text area is associated with the keyboard
}
Running effect

stay lv_example_keyboard_1 Function to add a key test to lose focus
static void lv_example_keyboard_1(void)
{
/*Create a keyboard to use it with an of the text areas*/
lv_obj_t* kb = lv_keyboard_create(lv_scr_act());
/*Create a text area. The keyboard will write here*/
lv_obj_t* ta;
ta = lv_textarea_create(lv_scr_act());
lv_obj_align(ta, LV_ALIGN_TOP_LEFT, 10, 10);
lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_ALL, kb);
lv_textarea_set_placeholder_text(ta, "Hello");
lv_obj_set_size(ta, 140, 80);
ta = lv_textarea_create(lv_scr_act());
lv_obj_align(ta, LV_ALIGN_TOP_RIGHT, -10, 10);
lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_set_size(ta, 140, 80);
lv_keyboard_set_textarea(kb, ta);
// The following is a new addition
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN); // Add keyboard hidden flag
lv_obj_t* btn = lv_btn_create(lv_scr_act()); // Create keys
lv_obj_align(btn, LV_ALIGN_TOP_MID, 0, 10); //LV_ALIGN_TOP_MID Alignment
lv_obj_t* label = lv_label_create(btn); // establish Label object
lv_label_set_text(label, "Press me"); // Set up Label Text content
}
Running effect

边栏推荐
- 一文概览2D人体姿态估计
- nowcoder重排链表
- 聊聊保证线程安全的 10 个小技巧
- MySQL triggers
- R language uses bwplot function in lattice package to visualize box plot and par Settings parameter custom theme mode
- Sqlserver functions, creation and use of stored procedures
- 【算法leetcode】面试题 04.03. 特定深度节点链表(多语言实现)
- Data warehouse interview question preparation
- leetcode:6109. Number of people who know the secret [definition of DP]
- The implementation of OSD on rk1126 platform supports color translucency and multi-channel support for Chinese
猜你喜欢

数据中台概念

WT588F02B-8S(C006_03)单芯片语音ic方案为智能门铃设计降本增效赋能

Explain of SQL optimization

【信息检索】分类和聚类的实验

leetcode:6110. 网格图中递增路径的数目【dfs + cache】

Digi XBee 3 RF: 4个协议,3种封装,10个大功能

迅为IMX6Q开发板QT系统移植tinyplay

Digi重启XBee-Pro S2C生产,有些差别需要注意

Codeforce:c. sum of substrings

Docker compose public network deployment redis sentinel mode
随机推荐
流行框架:Glide的使用
LVGL 8.2 Menu
10. (map data) offline terrain data processing (for cesium)
Leetcode t47: full arrangement II
Digi XBee 3 rf: 4 protocols, 3 packages, 10 major functions
MySQL triggers
MySQL的存储过程练习题
聊聊保证线程安全的 10 个小技巧
leetcode:6110. The number of incremental paths in the grid graph [DFS + cache]
AI与生命科学
数据中台概念
flink sql-client.sh 使用教程
【C语言】指针笔试题
Node mongodb installation
Test process arrangement (3)
Practical puzzle solving | how to extract irregular ROI regions in opencv
sql优化之explain
NowCoder 反转链表
sql优化之查询优化器
Query optimizer for SQL optimization