当前位置:网站首页>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
边栏推荐
- [information retrieval] link analysis
- LiveData
- LVGL 8.2 List
- Codeforce:c. sum of substrings
- 迅为IMX6Q开发板QT系统移植tinyplay
- Test process arrangement (2)
- [algorithm leetcode] interview question 04.03 Specific depth node linked list (Multilingual Implementation)
- 【云原生】我怎么会和这个数据库杠上了?
- 产业互联网则具备更大的发展潜能,具备更多的行业场景
- C language small commodity management system
猜你喜欢
Leetcode 61: rotating linked list
Sqlserver functions, creation and use of stored procedures
LVGL 8.2 Draw label with gradient color
No servers available for service: xxxx
Excel quickly merges multiple rows of data
阿里被裁员工,找工作第N天,猎头又传来噩耗...
leetcode:6110. The number of incremental paths in the grid graph [DFS + cache]
Leetcode T48:旋转图像
统计php程序运行时间及设置PHP最长运行时间
LVGL 8.2 Line wrap, recoloring and scrolling
随机推荐
第十七章 进程内存
redis 日常笔记
产业互联网则具备更大的发展潜能,具备更多的行业场景
开发中常见问题总结
Intelligence d'affaires bi analyse financière, analyse financière au sens étroit et analyse financière au sens large sont - ils différents?
R language ggplot2 visualization: gganimate package creates dynamic line graph animation (GIF) and uses transition_ The reveal function displays data step by step along a given dimension in the animat
【MySQL从入门到精通】【高级篇】(四)MySQL权限管理与控制
Nowcoder reverse linked list
How to operate and invest games on behalf of others at sea
Count the running time of PHP program and set the maximum running time of PHP
No servers available for service: xxxx
關於miui12.5 紅米k20pro用au或者povo2出現問題的解决辦法
codeforce:C. Sum of Substrings【边界处理 + 贡献思维 + 灵光一现】
leetcode:6110. 网格图中递增路径的数目【dfs + cache】
R language dplyr package summary_ If function calculates the mean and median of all numerical data columns in dataframe data, and summarizes all numerical variables based on conditions
Gin integrated Alipay payment
Test evaluation of software testing
Data warehouse interview question preparation
聊聊保证线程安全的 10 个小技巧
失败率高达80%,企业数字化转型路上有哪些挑战?