1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

add lv_btnm_get_pressed

This commit is contained in:
Gabor Kiss-Vamosi 2018-11-19 07:00:17 +01:00
parent 81634d410b
commit 892f2be487
2 changed files with 21 additions and 4 deletions

View File

@ -340,16 +340,27 @@ lv_btnm_action_t lv_btnm_get_action(const lv_obj_t * btnm)
return ext->action; return ext->action;
} }
/**
* Get the pressed button
* @param btnm pointer to button matrix object
* @return index of the currently pressed button (LV_BTNM_PR_NONE: if unset)
*/
uint16_t lv_btnm_get_pressed(const lv_obj_t * btnm)
{
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
return ext->btn_id_pr;
}
/** /**
* Get the toggled button * Get the toggled button
* @param btnm pointer to button matrix object * @param btnm pointer to button matrix object
* @return index of the currently toggled button (0: if unset) * @return index of the currently toggled button (LV_BTNM_PR_NONE: if unset)
*/ */
uint16_t lv_btnm_get_toggled(const lv_obj_t * btnm) uint16_t lv_btnm_get_toggled(const lv_obj_t * btnm)
{ {
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(ext->toggle == 0) return 0; if(ext->toggle == 0) return LV_BTNM_PR_NONE;
else return ext->btn_id_tgl; else return ext->btn_id_tgl;
} }
@ -581,7 +592,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
} }
#if USE_LV_GROUP #if USE_LV_GROUP
/*Leave the clicked button as pressed if this the focused object in a group*/ /*Leave the clicked button when releases if this not the focused object in a group*/
lv_group_t * g = lv_obj_get_group(btnm); lv_group_t * g = lv_obj_get_group(btnm);
if(lv_group_get_focused(g) != btnm) { if(lv_group_get_focused(g) != btnm) {
ext->btn_id_pr = LV_BTNM_PR_NONE; ext->btn_id_pr = LV_BTNM_PR_NONE;

View File

@ -147,11 +147,17 @@ const char ** lv_btnm_get_map(const lv_obj_t * btnm);
*/ */
lv_btnm_action_t lv_btnm_get_action(const lv_obj_t * btnm); lv_btnm_action_t lv_btnm_get_action(const lv_obj_t * btnm);
/**
* Get the pressed button
* @param btnm pointer to button matrix object
* @return index of the currently pressed button (LV_BTNM_PR_NONE: if unset)
*/
uint16_t lv_btnm_get_pressed(const lv_obj_t * btnm);
/** /**
* Get the toggled button * Get the toggled button
* @param btnm pointer to button matrix object * @param btnm pointer to button matrix object
* @return index of the currently toggled button (0: if unset) * @return index of the currently toggled button (LV_BTNM_PR_NONE: if unset)
*/ */
uint16_t lv_btnm_get_toggled(const lv_obj_t * btnm); uint16_t lv_btnm_get_toggled(const lv_obj_t * btnm);