Bug 165251 - Not enough information in Calendar control's SelectionEvent
Summary: Not enough information in Calendar control's SelectionEvent
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.3   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal with 2 votes (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Carolyn MacLeod CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 177776 178625 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-11-20 18:14 EST by Andre Weinand CLA
Modified: 2009-04-30 21:32 EDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Weinand CLA 2006-11-20 18:14:09 EST
I'm using a DateTime(SWT.CALENDAR) control in a date picker dialog.
When clicking on a 'day' the dialog should be dismissed, clicking
on the next/previous month/year arrows, the dialog should stay open.

Problem: the selection event does not provide any information about what part
of the dialog was clicked. In addition, the SelectionListener's widgetDefaultSelected
method is never called.

This is on MacOS X.
Comment 1 Carolyn MacLeod CLA 2006-11-21 16:31:46 EST
Can you add an OK button for now?

Historically, the SWT selection event does not provide additional information.
It is typically up to you to look at the control and see what changed.
I can see that that won't work for calendars because the day can change when the user changes the month, etc.

But, you're right, DefaultSelection is currently spec'ed to do nothing for DateTime on all platforms. So it could concievably be used to say "the user actually selected a day, they are not just navigating".

I see that the Windows calendar has an MCN_SELECT event that is sent "when the user makes an explicit date selection within a month calendar control".

The GTK calendar has a signal that is "Emitted when the user selects a day".

Mac Carbon doesn't have a calendar, so what you are seeing is emulated (so we can make it do anything as long as it's consistent with the other platforms).

I will run this by Steve when he gets back next week.
Comment 3 Steve Northover CLA 2006-11-28 16:24:52 EST
Normally, widgetDefaultSelected() is for "double clicking" or default action, not "single clicking".
Comment 4 Carolyn MacLeod CLA 2008-03-13 16:20:38 EDT
See also bug 177764.
Comment 5 Carolyn MacLeod CLA 2008-03-13 16:35:29 EDT
*** Bug 177776 has been marked as a duplicate of this bug. ***
Comment 6 Carolyn MacLeod CLA 2008-03-13 16:51:16 EDT
*** Bug 178625 has been marked as a duplicate of this bug. ***
Comment 7 Nobody - feel free to take it CLA 2008-08-03 20:08:01 EDT
So, are there any plans to introduce the DefaultSelection (widgetDefaultSelected()) event? Technically, it is acknowledged as possible and it's especially useful when the DateTime control is shown in a popup window that must go away...
Comment 8 Steve Northover CLA 2008-08-07 14:40:34 EDT
CAR, just fix this?
Comment 9 Steve Northover CLA 2008-08-08 13:21:13 EDT
We need to decide whether default selection will be send for single clicking.  Note that this is unexpected.  Normally, default selection is sent when the user double clicks or hits return.

If we decide against "default selection on single click", we use the detail field in the selection event.  This seems like the right thing to do to me.  If we decide to do this (the detail), we might also implement the "double clicking and return behavior" for default selection in addition to the detail field.
Comment 10 Benjamin Pasero CLA 2008-08-11 06:29:42 EDT
I second this request. Being able to distinguish between day-selections and navigation-selections would allow one to dismiss the dialog as soon as the date was explicitly changed without navigating. Using the detail field on the selection event seems like a good strategy. I am not sure if the default selection event is necessary at all then.
Comment 11 Nobody - feel free to take it CLA 2008-08-12 06:17:49 EDT
Well, the DefaultSelection event IS necessary.
Navigation and single-clicking on a calendar day should result in a Selection event being fired. On the contrary, double-clicking and <Enter> on a calendar day should produce a DefaultSelection event. These are the natural expectations.
The Event's detail field seems unnecessary, then.
Comment 12 Benjamin Pasero CLA 2008-08-12 06:31:22 EDT
Right. One might want to be able to close the calendar once a day was selected. You need the selected date as part of the selection event in this case to distinguish from a navigation event.
Comment 13 Nobody - feel free to take it CLA 2008-08-12 07:10:25 EDT
The DateTime class is endowed with some getXyz() methods that supply the currently chosen date and time at any point in code.
If navigation events and selection events (single-click only) can be told apart, then I suggest the detail field (which is of type "int", by the way) contained a constant from org.eclipse.swt.SWT indicating that it's about navigation action (maybe the TRAVERSE_* constants?).
Comment 14 Benjamin Pasero CLA 2008-08-12 07:53:50 EDT
Yes, I was thinking into the same direction.
Comment 15 Steve Northover CLA 2008-08-12 12:09:04 EDT
Released SWT.DefaultSelection code for Windows.
Comment 16 karthick CLA 2008-09-18 15:05:35 EDT
Just checking, is the default selection event now available?
Comment 17 karthick CLA 2008-09-29 19:13:33 EDT
Steve,

You said that the the SWT.DefaultSelection code is available for Windows. Is the patch available for general use, and for the other platforms?

Regards,
Karthick
Comment 18 Jean-Charles Burkhardt CLA 2008-11-08 16:13:09 EST
I have the same problem on windows and presumably on debian latter.
I want to show a DateTime calendar without the ok button.
When the user really chooses a day, I will get the day and close the dialog.
When the user just changes the month, i will not close the dialog.
I tried to test if the month had changed, but this is defeated in case the user chooses a day (pale grey color) outside the current month.
People here have suggested to detail the event so that we know if the user is navigating or making a decision. This would be very fine.
I read also about default selection, which is not quite clear for me, because I dont imagine the user double cliking or hitting enter on a calendar - but if it achieves the same result, why not ? 
As the last message here is dated september, may I ask if any correction is available ?
Comment 19 Carolyn MacLeod CLA 2009-04-29 17:05:03 EDT
Fixed > 20090429.

DefaultSelection is now implemented for calendar (double-click on date).
If you are using the DATE or TIME component of a DateTime, then DefaultSelection is sent when the user types CR.

Dialogs containing DateTime controls can now be closed on DefaultSelection.