diff --git a/src/lv_objx/lv_calendar.c b/src/lv_objx/lv_calendar.c index d5ceac9f8..ced804db9 100644 --- a/src/lv_objx/lv_calendar.c +++ b/src/lv_objx/lv_calendar.c @@ -317,11 +317,12 @@ lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar) * Get the the pressed date. * @param calendar pointer to a calendar object * @return pointer to an `lv_calendar_date_t` variable containing the pressed date. + * `NULL` if not date pressed (e.g. the header) */ lv_calendar_date_t * lv_calendar_get_pressed_date(const lv_obj_t * calendar) { lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); - return &ext->pressed_date; + return ext->pressed_date.year != 0 ? &ext->pressed_date : NULL; } /** diff --git a/src/lv_objx/lv_calendar.h b/src/lv_objx/lv_calendar.h index 83e489cc1..0ea914843 100644 --- a/src/lv_objx/lv_calendar.h +++ b/src/lv_objx/lv_calendar.h @@ -172,6 +172,7 @@ lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar); * Get the the pressed date. * @param calendar pointer to a calendar object * @return pointer to an `lv_calendar_date_t` variable containing the pressed date. + * `NULL` if not date pressed (e.g. the header) */ lv_calendar_date_t * lv_calendar_get_pressed_date(const lv_obj_t * calendar);