Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316498 - [widgets] Keyboard navigation inside the DateTime SWT.CALENDAR widget does not work on Cocoa
Summary: [widgets] Keyboard navigation inside the DateTime SWT.CALENDAR widget does no...
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5.2   Edit
Hardware: Macintosh Mac OS X
: P3 normal with 5 votes (vote)
Target Milestone: ---   Edit
Assignee: Scott Kovatch CLA
QA Contact: Silenio Quarti CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-10 13:27 EDT by Al B CLA
Modified: 2010-11-02 14:13 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Al B CLA 2010-06-10 13:27:31 EDT
Running the the snippet below on Windows or with Carbon, one can use the keyboard arrows to navigate inside the DateTime widget.  Also, the Page Up and Page Down keys change the month backwards and forwards.

However, these events are not triggered on Cocoa.


import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class Snippet250 {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new RowLayout());

		final DateTime calendar = new DateTime(shell, SWT.CALENDAR);
		calendar.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				System.out.println ("Calendar date selected (MM/DD/YYYY) = " + (calendar.getMonth () + 1) + "/" + calendar.getDay () + "/" + calendar.getYear ());				
			}
		});
		
		calendar.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
					System.out.println("calendar date changed");
				}
			}
		});

		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
Comment 1 Scott Kovatch CLA 2010-11-02 14:13:56 EDT
Unfortunately this is platform behavior. NSDatePicker doesn't support keyboard-based navigation. But, once bug 277638 is fixed you can make a DateTime with SWT.DATE and SWT.DROP_DOWN set and then use the keyboard to adjust the date elements. The calendar drop-down will update to match the textual date.