1.) I can't find a solution to get SWT hotkeys working. I have a menu bar with items, and I set Accelerators with the setAccelerator() method of the MenuItem class. I suspect, they get blocked by the ActiveX-Control. However, I am able to open the menu bar by holding down the alt key and the special character key of a MenuItem key (by "special character", I mean the character in the name of the MenuItem-text, which is underlined).
2.) If I only press the alt-key and release it immediately without pressing another key, I can see switching the menu to blue (indicating it's getting activated). But after that, the whole application blocks and I have to kill it.
Any ideas?
I tried to create a minimal example, which shows the described bevaviour:
Code: Select all
public class Main
{
private static Shell shell;
private static Display display;
/**
* @param args
*/
public static void main(String[] args)
{
display = new Display();
shell = new Shell(display);
Menu menuBar = new Menu(shell, SWT.BAR);
MenuItem header = new MenuItem(menuBar, SWT.CASCADE);
header.setText("&Header");
Menu ectrMenu = new Menu(shell, SWT.DROP_DOWN);
header.setMenu(ectrMenu);
MenuItem cancel = new MenuItem(ectrMenu, SWT.PUSH);
cancel.setText("&TestItem");
cancel.addSelectionListener(new SelectionListener()
{
@Override
public void widgetSelected(SelectionEvent arg0)
{
System.out.println("Test");
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0)
{
System.out.println("Test");
}
});
cancel.setAccelerator(SWT.CTRL + 'G');
shell.setMenuBar(menuBar);
GridLayout gridLayout = new GridLayout();
shell.setLayout(gridLayout);
OleFrame frame = new OleFrame(shell, SWT.NONE);
OleControlSite controlSite = new OleControlSite(frame, SWT.NONE, "PDFXCviewAx.CoPDFXCview");
controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
controlSite.doVerb(OLE.OLEIVERB_UIACTIVATE);
GridData gridData = new GridData(GridData.FILL_BOTH);
frame.setLayoutData(gridData);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}