Community
Participate
Working Groups
Build 20011120 - Linux Motif. The following example will open a Shell with one menu option. Ctrol+F6 will open a dialog with a table. ** A key listener is added to the table but the keypressed and keyreleased methods do not get called. Once "**" is fixed. Press Ctrol+F6 and hold control pressed. Press F6 again. The selection shoul be set to the next element and so on. When Ctrol is released, the dialog should close and the selection printed in the console. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ import org.eclipse.swt.widgets.*; import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.custom.*; public class AltTabTest { static int count = 0; public static void main(String[] args) { final Shell s = new Shell(); final Display d = s.getDisplay(); s.setBounds(100, 100, 600, 600); s.setMenuBar(new Menu(s,SWT.BAR)); s.getMenuBar().setVisible(true); MenuItem mii = new MenuItem(s.getMenuBar(),SWT.CASCADE); mii.setText("PRESS CTRL+F6"); Menu m = new Menu(s.getMenuBar()); mii.setMenu(m); MenuItem mi = new MenuItem(m,SWT.NONE); mi.setText("Open Dialog with Table"); mi.setAccelerator(SWT.CONTROL|SWT.F6); mi.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { final Shell s1 = new Shell (s,SWT.APPLICATION_MODAL); s1.setLayout(new FillLayout()); final Table t = new Table(s1,SWT.SINGLE | SWT.FULL_SELECTION); t.setHeaderVisible(true); t.setLinesVisible(true); TableColumn tc = new TableColumn(t,SWT.NONE); tc.setText("HEADER"); tc.setResizable(false); TableItem i = new TableItem(t,SWT.NONE); i.setText("AAAAAAAAAAA"); i = new TableItem(t,SWT.NONE); i.setText("BBBBBBBBBBBBB"); i = new TableItem(t,SWT.NONE); i.setText("CCCCCCCCCCC"); tc.pack(); t.pack(); s1.pack(); tc.setWidth(t.getClientArea().width); t.addKeyListener(new KeyListener(){ public void keyPressed(KeyEvent e){ System.out.println("key pressed: " + e.keyCode); if(e.keyCode == SWT.F6) { t.setSelection ((t.getSelectionIndex() + 1) % t.getItemCount()); } } public void keyReleased(KeyEvent e) { System.out.println("key released: " + e.keyCode); if(e.keyCode == SWT.CONTROL) { System.out.println (t.getSelection()[0].getText()); s1.close(); } } }); s1.setLocation(150,150); s1.open(); t.setSelection(2); t.setFocus(); while (!s1.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } } public void widgetDefaultSelected(SelectionEvent e){ } }); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } } }
Fixed by removing the focus proxy that the Table was using to get keyboard events.