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

Bug 476349

Summary: Accelerator keys on disabled buttons remain visible when they shouldn't
Product: [RT] RAP Reporter: John Gymer <jgymer>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M2   
Hardware: PC   
OS: Windows 7   
See Also: https://git.eclipse.org/r/#/c/55164/
Whiteboard:

Description John Gymer CLA 2015-09-01 11:08:49 EDT
In RAP, when a button that has an accelerator key is pressed (via the accelerator keyboard shortcut rather than clicking), an underscore remains visible on the button if the button becomes disabled.

Disabled buttons never gain nor lose these underscore characters.

Snippet to reproduce below... hold CTRL+ALT to show the accelerators on the buttons and press 'O' for the Open button. This triggers a secondary dialog to be popped up and the Open button is disabled. Note how the underscore on the 'O' of Open remains visible even though the button is now disabled.

Press Close on the pop-up to return to the main shell. Press 're-enable', and the underscore is still shown... you have to press CTRL+ALT again for the underscores to be shown/removed properly now that the button is enabled again.

Yes, it is minor, but would be nice to resolve for 3.1.


/* DEMONSTRATES accelerators staying visible on disabled buttons */
package bug.snippet;

import org.eclipse.rap.rwt.RWT;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Bugsy {
	Display display;
	Shell mainShell;
	Button openDlgBut;
	Button reenableBut;
	
	Shell secondaryShell;
	Button closeBut;

	public void begin() {
		display = new Display();
		
		mainShell = new Shell(display, SWT.APPLICATION_MODAL|SWT.CLOSE);
		display.setData(RWT.MNEMONIC_ACTIVATOR, "CTRL+ALT");
		mainShell.setFullScreen(true);
		mainShell.setText("Primary Fullscreen Shell");
		FormLayout layout = new FormLayout();
		mainShell.setLayout(layout);
		
		FormData fd;
		
		openDlgBut = new Button(mainShell, SWT.PUSH);
		openDlgBut.setText("&Open Dialog");
		fd = new FormData();
		fd.left = new FormAttachment(0, 10);
		fd.top = new FormAttachment(0, 90);
		fd.right = new FormAttachment(0,200);
		fd.bottom = new FormAttachment(0, 130);
		openDlgBut.setLayoutData(fd);
		openDlgBut.addSelectionListener(butSelectListener);

		reenableBut = new Button(mainShell, SWT.PUSH);
		reenableBut.setText("&Re-enable");
		fd = new FormData();
		fd.left = new FormAttachment(0, 10);
		fd.top = new FormAttachment(0, 150);
		fd.right = new FormAttachment(0,200);
		fd.bottom = new FormAttachment(0, 190);
		reenableBut.setLayoutData(fd);
		reenableBut.addSelectionListener(butSelectListener);

		mainShell.open();
	}

	SelectionListener butSelectListener = new SelectionListener() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			if (e.widget.equals(reenableBut)) {
				openDlgBut.setEnabled(true);
			}
			else if (e.widget.equals(openDlgBut)) {
				openDlgBut.setEnabled(false);

				secondaryShell = new Shell(display, SWT.APPLICATION_MODAL|SWT.CLOSE);
				secondaryShell.setFullScreen(false);
				secondaryShell.setBounds(200, 200, 400, 200);
				secondaryShell.setText("Secondary Pop-Up Dialog Shell");
				FormLayout layout = new FormLayout();
				secondaryShell.setLayout(layout);
				
				FormData fd;
				
				closeBut = new Button(secondaryShell, SWT.PUSH);
				closeBut.setText("Close");
				fd = new FormData();
				fd.left = new FormAttachment(0, 10);
				fd.top = new FormAttachment(0, 90);
				fd.right = new FormAttachment(100,-10);
				fd.bottom = new FormAttachment(0, 120);
				closeBut.setLayoutData(fd);
				closeBut.addSelectionListener(butSelectListener);

				secondaryShell.open();
			}
			else if (e.widget.equals(closeBut)) {
				secondaryShell.close();
				secondaryShell.dispose();
			}
		}
	
		@Override
		public void widgetDefaultSelected(SelectionEvent e) {
		}
	};

}
Comment 1 Ivan Furnadjiev CLA 2015-09-03 09:00:02 EDT
Fixed in master with change https://git.eclipse.org/r/#/c/55164/