Close Button for Calendar Widget (V9.2.2 & up)

I am using v9.2.2 & I also checked the latest master version.

It seems there is no ‘Close’ button specific to the Calendar widget (such as in a msgbox, where you can add a dedicated close button without creating a callback ).

If the user opens the calendar and then changes his mind, the only way they can close it is by selecting a date (which triggers their callback which should delete the calendar object).

My workaround is to create a ‘Close’ button at the right side of the header, with a callback to delete the calendar when clicked.

A close button on the lines of the msgbox widget would be very convenient.
for Example: lv_calendar_add_close_button(myCalendar)

– Royce

Hi,

What about something like this?

  lv_obj_t * msgbox = lv_msgbox_create(NULL);
  lv_msgbox_add_close_button(msgbox);
  lv_msgbox_add_title(msgbox, "Pick a date");
  lv_obj_t * calendar = lv_calendar_create(lv_msgbox_get_content(msgbox));
  lv_obj_center(calendar);
  lv_obj_add_flag(calendar, LV_OBJ_FLAG_IGNORE_LAYOUT);

image

@kisvegabor ,

Thanks for the reply.

Yes, I thought about that, but it takes up valuable real estate especially if you add the Header for year & month selection, especially for small displays (mine is a 4.3")

In which case there would be a message box header just for the close button, and another for the calendar, which won’t look so nice :slight_smile:

I am attaching an image of how my workaround looks like.

Hope the close button will be considered in upcoming version.

–Royce

I see what you mean, and actually it looks great! However, I’m not sure that the close button is generic enough to add a built-in feature for it.

Instead I suggest teaching people how to do it (pr anything else themselves). Would you mind adding your solution as an example here?

Your fix looks really good, Royce. Adding a close button like that is a clever idea for smaller screens. Maybe it’s not something to add as a default feature, but sharing your example would surely help others.

1 Like