Community
Participate
Working Groups
BF farn@ca.ibm.com (2001/04/06 12:41:51) TableTree with SWT.CHECK style. When the mouse is used to select a table item checkbox, two selection events are received with the same information. public void widgetSelected(com.ibm.swt.events.SelectionEvent e) { if (e.widget == tableTree && e.detail == SWT.CHECK) { TableTreeItem treeItem = (TableTreeItem) e.item; ... return; } } NOTES: VI (4/6/2001 2:57:25 PM) I ran the following example and I only got one selection event when I clicked on an item's checkbox in the TableTree. I did notice that when I clicked on the check box for the selected item I got two selection events, one for a selection and one for the check box. I ran the exact same code with a Table instead of a TableTree and got the same behaviour. Can you change the example to show the problem? public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); TableTree tree = new TableTree(shell, SWT.FULL_SELECTION | SWT.CHECK); String[] columnTitles = { "Column 1", "Column 2" }; int[] iColumnWeight = { 50, 50 }; TableLayout layoutTable = new TableLayout(); for (int i = 0; i < columnTitles.length; i++) { TableColumn tableColumn = new TableColumn(tree.getTable(), SWT.NONE); tableColumn.setText(columnTitles[i]); ColumnLayoutData cLayout = new ColumnWeightData(iColumnWeight[i], true); layoutTable.addColumnData(cLayout); } tree.getTable().setLayout(layoutTable); tree.getTable().setHeaderVisible(true); TableTreeItem item = new TableTreeItem(tree, SWT.NONE); item.setText("Item "); for (int j = 0; j < 10; j++) { TableTreeItem subItem = new TableTreeItem(item, SWT.NONE); subItem.setText(0, "Sub Item " + j); subItem.setText(1, "Sub Item " + j + " column 2"); } item.setExpanded(true); tree.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { System.out.println("Item " + ((Item) e.item).getText() + " was selected with check =" + (e.detail == SWT.CHECK)); } public void widgetDefaultSelected(SelectionEvent e) { System.out.println("Item " + ((Item) e.item).getText() + " was selected with check =" + (e.detail == SWT.CHECK)); } }); shell.open(); while (shell != null && !shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } BF (2001/04/06 15:55:22) I am using Windows 2000. The problem does not occur in the above test program on my system either. I will attempt to produce a failing scenario. BF (2001/04/11 08:03:48) Updated code with failing scenario. Fails in build 0.042 / 0.042b. VI (4/11/2001 9:51:27 AM) The failure is with Table. I believe what you are saying is that if you create a Table or TableTree with style FULL_SELECTION and click on any other column than the first column, this toggles the check box and sends the corresponding check box selection events. Why are two events being sent? The following code demonstrates the problem: public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table t = new Table(shell, SWT.FULL_SELECTION | SWT.CHECK); t.setHeaderVisible(true); String[] columnTitles = { "Column 1", "Column 2" }; for (int i = 0; i < columnTitles.length; i++) { TableColumn tableColumn = new TableColumn(t,SWT.NONE); tableColumn.setText(columnTitles[i]); tableColumn.setWidth(200); } for (int j = 0; j < 10; j++) { TableItem item = new TableItem(t, SWT.NONE); item.setText(new String[]{"Item "+j, "Click here"}); } t.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { System.out.println("Item " + ((Item) e.item).getText() + "was selected with check = " + (e.detail == SWT.CHECK)); } }); shell.open(); while (shell != null && !shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } SN (4/11/01 12:36:33 PM) Only happens when the table is single select.
PRODUCT VERSION: Eclipse build 0.042
This PR is really old and we fixed many bugs in this area. I just tried the example code that VI claims shows the problem and it doesn't. I found VI to see if she could make it happen and she can't. Closing.