Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 256054

Summary: [Cocoa] Implement Space bar toggle for checkboxes
Product: [Eclipse Project] Platform Reporter: Miles Parker <milesparker>
Component: SWTAssignee: Grant Gayed <grant_gayed>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: cocoakevin, kilaka, peter, skovatch
Version: 3.5   
Target Milestone: 3.5 M6   
Hardware: All   
OS: Mac OS X   
Whiteboard:

Description Miles Parker CLA 2008-11-20 22:24:29 EST
This should be way down the list, but following Mac HIG, the space bar should toggle checkboxes on and off when they have focus. I think radio buttons should cycle as well, but not sure on that one. Even some Apple apps break this now, but it is a really nice feature for a keyboard enabled app like Eclipse.
Comment 1 Kevin Barnes CLA 2009-02-02 13:12:02 EST
This works in ControlExample and in this simple test case:

        public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell(display);
	
		Button button = new Button(shell, SWT.CHECK);
		button.setText("check");
		button.pack();
	
		shell.setBounds(0, 0, 200, 75);
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
Comment 2 Scott Kovatch CLA 2009-02-02 16:37:32 EST
Go to Keyboard & Mouse preference panel. Click "Keyboard Shortcuts" and then set "Full keyboard access" to "All controls". That will do the right thing for buttons and popup menus (bug 252236).

That's the standard cocoa thing to do -- if you want this behavior all the time we need to special case for it in Button.
Comment 3 Grant Gayed CLA 2009-02-02 16:59:13 EST
The behaviour caused by this setting should be preserved for the user.  I see that Space does toggle the checkbox if "All controls" is selected, and doesn't otherwise.  So this is working as expected.

I'm not sure what you mean by radio buttons cycling.  The current behaviour is that Tab tabs into a radio group, and then radios within the group can be selected with the arrows.  This seems to match the behaviour I see in the System Preferences (once the "All controls" option is selected).  Should it be doing something different?
Comment 4 Miles Parker CLA 2009-02-02 17:12:05 EST
Hmm.. Does work for me under carbon but not on Cocoa. *However* I did just have to switch back to an earlier build (M4) so if more recent changes fixed it.. I'll check again when I get a newer build.
Comment 5 Miles Parker CLA 2009-02-02 17:20:00 EST
And yeah, Grant I think you're right about radio button behavior w/ arrows. Makes UI sense, I checked a couple of other apps and they all conform, and its more consistent w/ combo boxes.

Way OT, but since we're all Mac geeks, can someone else please confirm wether I'm correct about bug 232420? This drives me absolutely bonkers.


Comment 6 Kevin Barnes CLA 2009-03-04 18:43:15 EST
code in comment #1 works for me. Can we close this?
Comment 7 Miles Parker CLA 2009-03-04 18:49:02 EST
Yep, works for me now. Thanks.
Comment 8 Kevin Barnes CLA 2009-03-04 19:00:22 EST
fixed