Menu and field get focus at the same time [message #1693017] |
Tue, 21 April 2015 09:05 |
|
Using RAP 2.3 there seems to be a focus bug when a shell has both a menu bar and a field, with RWT.MNEMONIC_ACTIVATOR set... here is a snippet:
/* DEMONSTRATES Mnemonic Active Keys issue */
package bug.snippet;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.swt.SWT;
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.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class Bugsy {
Display display;
Shell shell;
Label lab;
public void begin() {
display = new Display();
display.setData(RWT.MNEMONIC_ACTIVATOR, "CTRL+ALT");
shell = new Shell(display, SWT.APPLICATION_MODAL|SWT.CLOSE);
shell.setFullScreen(true);
shell.setText("My Shell");
FormLayout layout = new FormLayout();
shell.setLayout(layout);
FormData fd;
Text myField = new Text(shell, SWT.BORDER|SWT.SINGLE);
myField.setText("");
myField.setMessage("Press CTRL+ALT then type an 'F' key!");
fd = new FormData();
fd.left = new FormAttachment(0, 10);
fd.top = new FormAttachment(0, 50);
fd.right = new FormAttachment(100,-10);
fd.bottom = new FormAttachment(0, 80);
myField.setLayoutData(fd);
Button myBut = new Button(shell, SWT.PUSH);
myBut.setText("My &Button");
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);
myBut.setLayoutData(fd);
Button myBut2 = new Button(shell, SWT.PUSH);
myBut2.setText("My &Other Button");
fd = new FormData();
fd.left = new FormAttachment(0, 10);
fd.top = new FormAttachment(0, 130);
fd.right = new FormAttachment(100,-10);
fd.bottom = new FormAttachment(0, 160);
myBut2.setLayoutData(fd);
Menu myMenu = new Menu(shell, SWT.BAR);
MenuItem menuItemFile = new MenuItem(myMenu, SWT.CASCADE);
menuItemFile.setText("&File");
shell.setMenuBar(myMenu);
shell.open();
}
}
Very simple example, with a menu bar containing just a file menu, plus a field (Text) and a couple of Buttons with mnemonics defined.
Run this snippet and press CTRL+ALT to see the mnemonics. Just press CTRL+ALT once and the menu bar gets some sort of focus, but the keyboard caret stays in the Text entry field. If you now press the 'f' key, it chooses the 'File' menu (because this has focus and has 'F' defined as its mnemonic), but you also get an 'F' character appear in the field.
It is like both controls (menu and text field) have focus, so both get the keyboard event sent to them.
This does not happen in SWT, so presumably it is a RAP bug?
Could someone please confirm, and I'll raise a bug report if I haven't misunderstood how it is supposed to work?
Thanks, John
---
Just because you can doesn't mean you should
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02134 seconds