当前位置:网站首页>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
边栏推荐
- 商业智能BI财务分析,狭义的财务分析和广义的财务分析有何不同?
- R language ggplot2 visualization: gganimate package creates animated graph (GIF) and uses anim_ The save function saves the GIF visual animation
- leetcode:6110. The number of incremental paths in the grid graph [DFS + cache]
- LiveData
- Detailed explanation of visual studio debugging methods
- MySQL的触发器
- 【算法leetcode】面试题 04.03. 特定深度节点链表(多语言实现)
- 迅为IMX6Q开发板QT系统移植tinyplay
- No servers available for service: xxxx
- 【云原生】我怎么会和这个数据库杠上了?
猜你喜欢
Node mongodb installation
Leetcode T48: rotating images
Docker compose public network deployment redis sentinel mode
【MySQL从入门到精通】【高级篇】(四)MySQL权限管理与控制
leetcode:6110. 网格图中递增路径的数目【dfs + cache】
leetcode:6109. Number of people who know the secret [definition of DP]
flink sql-client.sh 使用教程
LVGL 8.2 Line wrap, recoloring and scrolling
10. (map data) offline terrain data processing (for cesium)
flink sql-client. SH tutorial
随机推荐
数据湖(十三):Spark与Iceberg整合DDL操作
MySQL的存储过程练习题
一种架构来完成所有任务—Transformer架构正在以一己之力统一AI江湖
SqlServer函数,存储过程的创建和使用
Leetcode 61: 旋转链表
Stm32f1 and stm32subeide programming example -max7219 drives 8-bit 7-segment nixie tube (based on GPIO)
LVGL 8.2 Draw label with gradient color
《opencv学习笔记》-- 线性滤波:方框滤波、均值滤波、高斯滤波
What is the difference between Bi financial analysis in a narrow sense and financial analysis in a broad sense?
Oppo find N2 product form first exposure: supplement all short boards
LVGL 8.2 text shadow
2022 game going to sea practical release strategy
Free, easy-to-use, powerful lightweight note taking software evaluation: drafts, apple memo, flomo, keep, flowus, agenda, sidenote, workflow
C language small commodity management system
【C语言】指针笔试题
Ruiji takeout notes
Detailed analysis of pytorch's automatic derivation mechanism, pytorch's core magic
Ml: introduction, principle, use method and detailed introduction of classic cases of snap value
R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graph, and uses the by parameter to specify the groupin
Chapter 17 process memory