Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Menu and field get focus at the same time(With RWT.MNEMONIC_ACTIVATOR the Menu and a Text field get focus together)
Menu and field get focus at the same time [message #1693017] Tue, 21 April 2015 05:05 Go to next message
Eclipse UserFriend
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
Re: Menu and field get focus at the same time [message #1693036 is a reply to message #1693017] Tue, 21 April 2015 07:22 Go to previous messageGo to next message
Eclipse UserFriend
Hi John,
looks like a bug to me. Please file a bugzilla and attach your test
snippet there.
Thanks,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Menu and field get focus at the same time [message #1693038 is a reply to message #1693036] Tue, 21 April 2015 07:36 Go to previous message
Eclipse UserFriend
Thanks Ivan... bug raised:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=465098
Previous Topic:RAP E4 out of incubator ?
Next Topic:BrowserFunction - listening for JS functions via JavaScriptExecutor/Loader
Goto Forum:
  


Current Time: Sun Jul 13 07:03:13 EDT 2025

Powered by FUDForum. Page generated in 0.04391 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top