当前位置:网站首页>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

边栏推荐
- 软件测试之测试评估
- Matters needing attention in overseas game Investment Agency
- Solutions aux problèmes d'utilisation de l'au ou du povo 2 dans le riz rouge k20pro MIUI 12.5
- AI and Life Sciences
- 商業智能BI財務分析,狹義的財務分析和廣義的財務分析有何不同?
- LVGL 8.2 keyboard
- Test process arrangement (3)
- LVGL 8.2 Line wrap, recoloring and scrolling
- Test process arrangement (2)
- Gin integrated Alipay payment
猜你喜欢

Node mongodb installation

Intelligence d'affaires bi analyse financière, analyse financière au sens étroit et analyse financière au sens large sont - ils différents?

codeforce:C. Sum of Substrings【边界处理 + 贡献思维 + 灵光一现】

基于51单片机的超声波测距仪

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

Digi restarts XBee Pro S2C production. Some differences need to be noted

RK1126平台OSD的实现支持颜色半透明度多通道支持中文

Leetcode T48:旋转图像

【C语言】指针笔试题

Docker compose public network deployment redis sentinel mode
随机推荐
Talk about 10 tips to ensure thread safety
阿里被裁员工,找工作第N天,猎头又传来噩耗...
迅为IMX6Q开发板QT系统移植tinyplay
Chapter 17 process memory
R language uses bwplot function in lattice package to visualize box plot and par Settings parameter custom theme mode
Query optimizer for SQL optimization
Leetcode 61: 旋转链表
LVGL 8.2 Draw label with gradient color
第十七章 进程内存
Excel quickly merges multiple rows of data
商業智能BI財務分析,狹義的財務分析和廣義的財務分析有何不同?
AI与生命科学
The failure rate is as high as 80%. What are the challenges on the way of enterprise digital transformation?
The implementation of OSD on rk1126 platform supports color translucency and multi-channel support for Chinese
Matters needing attention in overseas game Investment Agency
Gin integrated Alipay payment
Count the running time of PHP program and set the maximum running time of PHP
Industrial Internet has greater development potential and more industry scenarios
Digi重启XBee-Pro S2C生产,有些差别需要注意
An overview of 2D human posture estimation