Project: SWT
Bug 174180 Table.getItem(Point) always returns null when first column is 0 pixels wide
Reported: 2007-02-14 10:56:07 | Status: resolved fixed

Build ID: M20060921-0945 Steps To Reproduce: This snippet shows the bug. It should print out the item to stdout when hovering, but when the width is 0, it always gets null. This snippet works properly on Windows and GTK. import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; public class Test { static boolean works = false; public static void main(String[] args) { Display display = new Display(); Shell s = new Shell(display); s.setLayout(new FillLayout()); s.setSize(300,400); final Table t = new Table(s, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER); TableColumn col = new TableColumn(t, SWT.LEFT, 0); if (works) col.setWidth(1); else col.setWidth(0); TableColumn col2 = new TableColumn(t, SWT.LEFT, 1); col2.setWidth(250); for (int i = 0; i < 10; i++) { new TableItem(t, SWT.NONE).setText(1, "FOobarrrr " + i); } t.addMouseMoveListener(new MouseMoveListener() { public void mouseMove(MouseEvent arg0) { TableItem item = t.getItem(new Point(arg0.x, arg0.y)); if (item == null) System.out.println("No item??"); else System.out.println("Hovering on " + item.getText(1)); } }); s.open(); while (!s.isDisposed()) if (!display.readAndDispatch()) display.sleep(); } }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java