From 084cc07d5308aea6c04f0a879aab7653ddcf3396 Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Fri, 26 Nov 2021 13:28:11 +0200 Subject: [PATCH] fix(keyboard): add missing functions (#2835) Related: https://forum.lvgl.io/t/keyobard-get-active-btn-text/5683/9?u=amirgon --- src/extra/widgets/keyboard/lv_keyboard.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/extra/widgets/keyboard/lv_keyboard.h b/src/extra/widgets/keyboard/lv_keyboard.h index 4b867c282..db6d55b83 100644 --- a/src/extra/widgets/keyboard/lv_keyboard.h +++ b/src/extra/widgets/keyboard/lv_keyboard.h @@ -139,6 +139,28 @@ static inline const char ** lv_keyboard_get_map_array(const lv_obj_t * kb) return lv_btnmatrix_get_map(kb); } +/** + * Get the index of the lastly "activated" button by the user (pressed, released, focused etc) + * Useful in the the `event_cb` to get the text of the button, check if hidden etc. + * @param obj pointer to button matrix object + * @return index of the last released button (LV_BTNMATRIX_BTN_NONE: if unset) + */ +static inline uint16_t lv_keyboard_get_selected_btn(const lv_obj_t * obj) +{ + return lv_btnmatrix_get_selected_btn(obj); +} + +/** + * Get the button's text + * @param obj pointer to button matrix object + * @param btn_id the index a button not counting new line characters. + * @return text of btn_index` button + */ +static inline const char * lv_keyboard_get_btn_text(const lv_obj_t * obj, uint16_t btn_id) +{ + return lv_btnmatrix_get_btn_text(obj, btn_id); +} + /*===================== * Other functions *====================*/