Inoperational shortcuts [message #334201] |
Mon, 26 January 2009 10:22  |
Eclipse User |
|
|
|
I posted this last week in *.swt, but that seems to have been the wrong
target
audience. In the JFace snippet below, the only interesting part is
createMenuManager(). I create a menu with a shortcut. However, the shortcut
is inoperational, that is, pressing CTRL-G does nothing. But once I have
opened the drop-down menu, the shortcut starts to work.
The delayed construction of MenuItem seems to harm the functionality here.
What can I do to circumvent that? I’m working under Windows, but it won’t
work for GTK either, I am told.
Bye,
Mike
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
public class ShortcutSnippet extends ApplicationWindow {
public ShortcutSnippet() {
super(null);
addMenuBar();
}
public static void main(final String args[]) {
final ApplicationWindow w = new ShortcutSnippet();
w.setBlockOnOpen(true);
w.open();
}
@Override
protected MenuManager createMenuManager() {
final MenuManager bar_menu = new MenuManager("");
final MenuManager dropdown_menu= new MenuManager("File");
dropdown_menu.add(new Action() {
{
setText("Greet");
setAccelerator(SWT.MOD1 | 'G');
}
@Override
public void run() {
MessageDialog.openInformation(null,
"Greet", "Hello World");
}
});
bar_menu.add(dropdown_menu);
return bar_menu;
}
}
--
Michael Piefel
netCCM GmbH
|
|
|
|
Powered by
FUDForum. Page generated in 0.04910 seconds