SelectionListener on Buttons type SWT.RADIO [message #660248] |
Thu, 17 March 2011 10:34  |
Eclipse User |
|
|
|
Snippet:
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
SelectionListener selectionListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Button btn = (Button) e.getSource();
System.out.println("Event on '" + btn.getText() + "' -
selection = " + btn.getSelection());
}
};
Button btn1 = new Button(composite, SWT.RADIO);
btn1.setText("Button 1");
btn1.addSelectionListener(selectionListener);
Button btn2 = new Button(composite, SWT.RADIO);
btn2.setText("Button 2");
btn2.addSelectionListener(selectionListener);
btn1.setSelection(true);
When run this snippet and click to Button 2 then becomes:
Event on 'Button 1' - selection = false
Event on 'Button 2' - selection = true
but I expect only:
Event on 'Button 2' - selection = true
Is it feature or bug ?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09395 seconds