From a42b56c7c754906f7df0ee5aa9933285f85e9e94 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 16 Jan 2018 15:35:35 +0100 Subject: [PATCH] lv_roller: add missing action handling --- lv_objx/lv_roller.c | 2 ++ lv_objx/lv_roller.h | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index c3bdb31f1..4b6c9c488 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -351,6 +351,7 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, if(id < 0) id = 0; if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1; ext->ddlist.sel_opt_id = id; + if(ext->ddlist.action) ext->ddlist.action(roller); } else if(sign == LV_SIGNAL_RELEASED) { /*If picked an option by clicking then set it*/ @@ -362,6 +363,7 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, if(id < 0) id = 0; if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1; ext->ddlist.sel_opt_id = id; + if(ext->ddlist.action) ext->ddlist.action(roller); } } diff --git a/lv_objx/lv_roller.h b/lv_objx/lv_roller.h index cb7b19641..f970bbfbe 100644 --- a/lv_objx/lv_roller.h +++ b/lv_objx/lv_roller.h @@ -71,6 +71,17 @@ static inline void lv_roller_set_options(lv_obj_t * roller, const char * options */ void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en); + +/** + * Set a function to call when a new option is chosen + * @param roller pointer to a roller + * @param action pointer to a callback function + */ +static inline void lv_roller_set_action(lv_obj_t * roller, lv_action_t action) +{ + lv_ddlist_set_action(roller, action); +} + /** * Set the height to show the given number of rows (options) * @param roller pointer to a roller object