wx.adv.CalendarCtrl question

Control has very nice visuals; however I do not understand the date selection behavior.

  1. Just after creation - calendar on screen - There is a date highlighted (usually today’s date). Single click on this date. Control does not respond to the EVT_CALENDAR_DAY event no matter how many time you click on the date.
  2. Click on a different date in the month - it works as expected.
  3. Click on original date - today’s date - it works as expected.
  4. The same is true if you go to another month. When the newly chosen month appears the 1st of the month is highlighted. Click as often as you want - nothing happens.
    This is a big problem for me because:
  5. It confuses users.
  6. The calendar control returns an unused date which is difficult to dispose of.

Any ideas how to get around this problem?

Thanks in advance…


First of all, the EVT_CALENDAR_DAY event is no longer documented and is deprecated. It may disappear in some future release.

Next, since the names of most of the events that are documented include _CHANGED then you can assume that they only fire when the selection is changed to a new one. I expect that the deprecated EVT_CALENDAR_DAY event is probably mapped to the current EVT_CALENDAR_SEL_CHANGED event, so given that you can probably see an explanation for the behavior you are seeing.

The EVT_CALENDAR event will be sent upon double-clicking a date, regardless of whether it was previously selected or not. Perhaps that will fit your needs?

Finally, it looks like the GenericCalendarCtrl does send the EVT_CALENDAR_SEL_CHANGED event when clicking on an already selected day, so that could be a way forward for you too.

Thanks for the quick reply. Yes, it has been deprecated. I did try EVT_CALENDAR_SEL_CHANGED. It has the same problem. Even double-click doesn’t work. In addition it responds to events other than picking a date like, for example, changing the month. I might just want to move 3 months into the future for a new date pick. Instead, I get 3 additional dates (1st of each month) returned. It makes sense, I guess. I can get around these problems by using some other (non calendar) event to read the calendar date except for the startup problem. If the user starts the program and immediately selects the current date (it’s highlighted) I get no event. I can still get the correct date by reading the calendar date but the fact that a calendar selection has occurred is lost. I can make it work.
It’s just me muttering.


with the GenericCalendarCtrl catch
EVT_CALENDAR_DAY to get the day by a simple select or
EVT_CALENDAR for a double klick
(changing a page: month, year etc, is only caught by EVT_CALENDAR_PAGE_CHANGED)

Thanks. It’s all working now. I did away with the deprecated EVT_CALENDAR_DAY and EVT_CALENDAR_SEL_CHANGED and went with just polling the calendar on an as needed basis. Not as elegant but it works.

Many thanks,

well, I don’t want to press on, but when I was somewhat younger we read about Time & motion study and by making a calendar entry a Button and wrap the GenericCalendarCtrl around it, it takes 2 klicks by using EVT_CALENDAR_DAY, or 1 and a double klick by using EVT_CALENDAR (only the date picker is faster, especially when the default day is the one looked for)
so what can be more elegant?