From 935c79feb82165e123123b045719626591372b76 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 24 May 2021 19:47:09 +0900 Subject: [PATCH] Add new API to send information about the clicked key Change-Id: Icdee44c84266753771ef419592fbf79b1f4ec65b --- capi/include/cscl-ui-nui.h | 3 +++ capi/src/cscl-ui-nui.cpp | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/capi/include/cscl-ui-nui.h b/capi/include/cscl-ui-nui.h index 2449626..83d938a 100644 --- a/capi/include/cscl-ui-nui.h +++ b/capi/include/cscl-ui-nui.h @@ -49,6 +49,7 @@ typedef void (*scl_nui_draw_rectangle_cb)(int pos_x, int pos_y, int width, int h /* window backend */ typedef void (*scl_nui_update_window_cb)(int x, int y, int width, int height, void* user_data); +typedef int (*scl_nui_key_click_event_cb)(SclUIEventDesc event_desc); int scl_nui_init(const char *entry_filepath); int scl_nui_fini(); @@ -65,6 +66,8 @@ int scl_nui_set_string_substitution(const char *original, const char *substitute int scl_nui_set_update_window_cb(scl_nui_update_window_cb callback, void *user_data); +int scl_nui_set_key_click_event_cb(scl_nui_key_click_event_cb callback); + #ifdef __cplusplus } #endif diff --git a/capi/src/cscl-ui-nui.cpp b/capi/src/cscl-ui-nui.cpp index 02f4d7d..4f74987 100644 --- a/capi/src/cscl-ui-nui.cpp +++ b/capi/src/cscl-ui-nui.cpp @@ -50,6 +50,8 @@ static void *g_draw_rectangle_cb_data = NULL; static scl_nui_update_window_cb g_update_window_cb = NULL; static void *g_update_window_cb_data = NULL; +static scl_nui_key_click_event_cb g_key_click_event_cb = NULL; + void CUIGraphicsBackendCallback::on_draw_text(const SclFontInfo& font_info, const SclColor& color, const char *str, int pos_x, int pos_y, int w, int h, SCLLabelAlignment align, int padding_x, int padding_y, int inner_width, int inner_height, void* user_data) //const char *str, int x, int y, int w, int h, int fontsize, void* user_data) @@ -110,7 +112,12 @@ void CUIWindowBackendCallback::update_window(int x, int y, int width, int height SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_desc) { LOGI(""); - return SCL_EVENT_PASS_ON; + int ret = 0; + if (g_key_click_event_cb) { + ret = g_key_click_event_cb(event_desc); + } + + return (SCLEventReturnType)ret; } SCLEventReturnType CUIEventCallback::on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info) @@ -266,3 +273,10 @@ EXPORT_API int scl_nui_set_update_window_cb(scl_nui_update_window_cb callback, v return 0; } + +EXPORT_API int scl_nui_set_key_click_event_cb(scl_nui_key_click_event_cb callback) +{ + g_key_click_event_cb = callback; + + return 0; +} \ No newline at end of file -- 2.34.1