当前位置:网站首页>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
边栏推荐
- GCC [6] - 4 stages of compilation
- 迅为IMX6Q开发板QT系统移植tinyplay
- Opencv3.2 and opencv2.4 installation
- Query optimizer for SQL optimization
- Some problems and ideas of data embedding point
- Pandora IOT development board learning (RT thread) - Experiment 3 button experiment (learning notes)
- remount of the / superblock failed: Permission denied
- Data Lake (13): spark and iceberg integrate DDL operations
- Combined with case: the usage of the lowest API (processfunction) in Flink framework
- [algorithm leetcode] interview question 04.03 Specific depth node linked list (Multilingual Implementation)
猜你喜欢
【MySQL从入门到精通】【高级篇】(四)MySQL权限管理与控制
Real time data warehouse
92. (cesium chapter) cesium building layering
Leetcode 61: rotating linked list
Xcode abnormal pictures cause IPA packet size problems
[information retrieval] link analysis
LVGL 8.2 LED
A keepalived high availability accident made me learn it again
No servers available for service: xxxx
【信息检索】链接分析
随机推荐
Excel quickly merges multiple rows of data
利用Shap值进行异常值检测
Map of mL: Based on Boston house price regression prediction data set, an interpretable case of xgboost model using map value
Industrial Internet has greater development potential and more industry scenarios
R language uses bwplot function in lattice package to visualize box plot and par Settings parameter custom theme mode
[cloud native] how can I compete with this database?
What is the difference between Bi financial analysis in a narrow sense and financial analysis in a broad sense?
统计php程序运行时间及设置PHP最长运行时间
Alcohol driving monitoring system based on stm32+ Huawei cloud IOT design
C language programming
A keepalived high availability accident made me learn it again
Compile oglpg-9th-edition source code with clion
Ruiji takeout notes
Nowcoder rearrange linked list
Sqlserver functions, creation and use of stored procedures
Visual Studio调试方式详解
Nowcoder reverse linked list
關於miui12.5 紅米k20pro用au或者povo2出現問題的解决辦法
First experience of ViewModel
Leetcode T47: 全排列II