| Jface accelerator key not working on macOS when focus is on StyledText widget [message #1779437] |
Sun, 07 January 2018 20:17  |
Eclipse User |
|
|
|
Hello,
Within a StyledText or Text widget, a single letter key accelerator is working fine on Windows. However, it is not working on macOS:
- All good on Windows: pressing 'A' when the text view is focused displays the pop-up (and the letter A is not output)
- Fail on macOS: pressing 'A' when the text view is focused does NOT display the pop-up (and the letter A is output)
I'm using the latest version of SWT and Jface packages (provided with Eclipse Oxygen.2). Testing on macOS High Sierra 10.13.
(Note that making the StyledText READ_ONLY at construction does not mitigate the problem; the key still gets processed by the text widget instead of the Jface key binding manager.)
Simple demo snippet below. Any help would be greatly appreciated! Thanks. (I also posted this question on SO: q/48141897/950494).
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Decorations;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
public class AcceleratorsTest {
static class ActionTest extends Action {
ActionTest() {
super("Sample Action");
setAccelerator('A');
}
@Override
public void run() {
MessageDialog.openInformation(null, "hello", "hello");
}
}
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
// menu with one action having the accelerator key 'A'
MenuManager menuManager = new MenuManager();
Menu menu = menuManager.createMenuBar((Decorations)shell);
shell.setMenuBar(menu);
MenuManager menuFile = new MenuManager("File");
menuFile.add(new ActionTest());
menuManager.add(menuFile);
menuManager.updateAll(true);
// text widget fills up the main shell
StyledText text = new StyledText(shell, SWT.BORDER | SWT.READ_ONLY);
text.setText("Accelerators problem inside StyledText:\r\n"
+ " - okay on Windows: pressing A when the text view is focused displays the pop-up (and the letter A is not output)<br>\r\n"
+ " - fail on macOS: pressing A when the text view is focused does NOT display the pop-up (and the letter A is output)");
// event loop
shell.open();
while(!shell.isDisposed()) {
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04026 seconds