wxCalendar event priority Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 423
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

wxCalendar event priority

Post by raananb » Sun May 10, 2020 1:40 pm

wxCalendar provides EVT_CALENDAR_SEL_CHANGED, EVT_CALENDAR_YEAR and EVT_CALENDAR_MONTH.

When the three events are used in an application, EVT_CALENDAR_SEL_CHANGED is fired before EVT_CALENDAR_YEAR or EVT_CALENDAR_MONTH, which makes it difficult (for me) to avoid unnecessary functional problems.

For example: if a selected date should be between 2019/07/01 and 2020/06/30, then when 2019 is selected at the top of the widget, EVT_CALENDAR_SEL_CHANGED catches the event before EVT_CALENDAR_YEAR can do anything and raises an error since it detects that wxCalendar (automatically) selected 2019/01/01 which is not within the accepted range.

If there was a way to change the order of events and process EVT_CALENDAR_YEAR before EVT_CALENDAR_SEL_CHANGED, then it would be possible to indicate that only a year was selected (for example, by settting the date to 2019/00/00 in the handler of EVT_CALENDAR_YEAR) and have EVT_CALENDAR_SEL_CHANGED ignore that date and only check the validity of a date when EVT_CALENDAR_SEL_CHANGED is fired with a real date (which, of course can be out of bounds, but that is what the contorl is for).

alternatively, can wxCalendar be modified to return a 'void' date when the year or the month is modified (on all platforms)?

Does anyone know if and how this can be achieved?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4058
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxCalendar event priority

Post by ONEEYEMAN » Sun May 10, 2020 5:48 pm

Hi,
About modifying the sources - you should sent an e-mail to wx-users ML.

Thank you.

raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 423
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: wxCalendar event priority

Post by raananb » Sun May 10, 2020 8:22 pm

I added EVT_CALENDAR_DAY, moved most of the code from EVT_CALENDAR_SEL_CHANGED to EVT_CALENDAR_DAY and removed EVT_CALENDAR_SEL_CHANGED.

This solved the problem.

Thanks for the suggestion.

Post Reply