I’ve got a DesktopListbox cell that when clicked popups a DateTimePicker in a small window. I grab the selected date with the DateChanged event and process (works fine). However, if the selected date happens to be the current date (I’m just using as “date”, no time component) the control does not seem to process it; nothing happens. None of the available events seems to fire. The calendar just sits there twiddling its thumbs. Is there an event I’m missing here or a “trick” to recognizing the current date has been “clicked”? Using the latest version of Xojo on a new MacBookPro. Thanks!
Update: Still playing with this. So far the only way I’m able to update my listbox cell value is by using the DateTimePicker “closing” event and I compare: If DateTimePicker.SelectedDate.SQLDate = DateTime.Now.SQLDate Then…process it and the listbox cell updates. The control is in another small window that popups up, not sure if that’s why it doesn’t process the same day click (doubt it, will test). Seems silly that the control will not process a same day selection. What if you need to update a date to today’s date? There’s no event to capture that. This all works but the user has to close the window rather than closing it programmatically with a selection.
so I can’t select the same date on the calendar to see if DateChanged is firing.
I remember discussion that Windows fires DateChanged even if the date is not changed, maybe Mac does not fire DateChanged if the date did not change?
Edit: maybe Xojo can add a method called “DateClicked” or something like that that fires even if the user select the same date? and not only DateChanged.
BTW: This is bc. on Windows the “Graphical” DateTime Picker is just a line with a DropOut Calendar and on Mac it’s a real Graphical Calendar. (I assume Xojo Inc. thinks that things like this making Cross Dev. a bit more interesting…)
Of course I did, but your example doesn’t tackle the problem.
OP DateChanged event doesn’t fire if the same date is clicked on. Can Xojo provide DateClicked event for this need? Should we use other events like MouseUp/Down or KeyUp/Down to try to find if the user is trying to select the same date?
For a Xojo user stand point is easier to have DateClicked and come up with code to know if DateChanged, but with DateChanged is harder to receive information if user selected the same date.
Now i get it. Thank you.
I’ve always clicked on the “Today” Button at the bottom of the Calendar, not onto the actual Date-Number within the Calendar Graphic.
I’ve interpreted it like “DateChanged event doesn’t fire if the selected date is today”, not “the same date” (in other words, if you select another date and come back to today, it won’t fire the second time).
As long as the date is changed, the DateChanged event will fire.
If the same date is clicked/selected, then DateChanged event won’t fire.
I guess this is designed this way, that’s why the name.
The problem is that OP wants to know when the user selected a date, even if the same date, so code can be executed (maybe just closing the window). DateChanged event will not fire for this need.
Just tried to use MouseDown/Up and can’t make it work (does not fire). I can make MouseUp fire on a DesktopTextField, so maybe DesktopDateTimePicker doesn’t work?
Yes, I agree, but I read the question as “it doesn’t work that way for me/it’s broken”. If you read it again, you’ll notice the question mentions “selecting today”, not “selecting the same date”.
On my Mac I’m clicking on the current date, it’s highlighted. So there’s no change to the DatePicker. So trying to change a date to the current date won’t fire the event. I did not see a “Today” button/selector. Will check that. Or perhaps code one in; that may be the answer.
Thanks for clarifying the problem. I’m seeing it as well (selecting the already-selected date doesn’t raise an event). You may fill a feature request.
Another workaround would be to check with a combination of timer/KeyDown events. The DateTimePicker control has a working KeyDown event (but no MouseDown event, as Alberto already mentioned; possibly another bug to report); the MouseEnter and MouseExit events also work. You could start a timer in MouseEnter, stop it in MouseExit, and monitor when the selection changes; include the KeyDown even for when the user has moved the mouse out of the control but it still has the focus (or have the timer always run regardless of the events, but I find it less elegant).
BTW: may I ask you what you’re trying to solve in wanting an event to happen when re-selecting the same date? Maybe there’s another way for accessing your goal
William close the window when the event fires (DateChanged), because if the same date is selected, there is no event that fires, so there is no way to close the window the same way as clicking any other date.
Tried to upvote these but for some reason I’m not able to connect to that feature. I’ll try later. I’ve got a Listbox with a cell as text and put the selected date into it as text. Works fine except for this issue. The DateChanged and MouseDown events don’t seem to fire if it’s today’s date.
You have to do it in the Feature request, not the forum. Click the link and then look for the thumbs up. You have to be logged in to the bug report system, which you can do with you’re Xojo account.