Note that there are some explanatory texts on larger screens.

plurals
  1. POEclipse Table widget with SWT.CHECK is fireing two events when a TableItem is selected
    text
    copied!<p>I'm making an Eclipse (3.6.2) CDT (7.0.2) Plugin which uses my own wizard page (extending MBSCustomPage). This wizard page shows a Table filled with some TableItems that can be checked or unchecked by clicking on them (as usual). <strong>The problem is that I'm always receiving two events when a TableItem checkbox is cheked (or unchecked)!</strong>. In the first event received, I have a (SelectedEvent)e.detail == SWT.CHECK, even if the TableItem was checked first, and in the second event, the (SelectedEvent)e.detail == 0!. So I have no way to know if the TableItem is really checked or not. This is my code (somewhat):</p> <pre><code>final Table table = new Table( composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION | SWT.CHECK ); table.setHeaderVisible(true); table.setLinesVisible(false); (...) table.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { CheckThatOnlyOneItemCanBeCheckedAtTime(e.item); //If someone check on me, save the item data value in a "container" if( e.detail == SWT.CHECK ) { MBSCustomPageManager.addPageProperty(PAGE_ID, "SDK_Path", ((ISdk)((TableItem)e.item).getData()).getPath() ); } else { //Otherwise, unset the saved value MBSCustomPageManager.addPageProperty(PAGE_ID, "SDK_Path", "" ); } } }); </code></pre> <p>Why is widgetSelected() being called two times when I click on the checkbox of a TableItem? I tested that the events are fired even if there is no code inside the widgetSelected() method. I didn't find anything Googling around or looking in Eclipse Bugzilla database... really strange to me, but I'm not an experienced Eclipse plugin coder (not even Java) :)</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload