[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: ToolItem SelectionEvent
|
Thanks Emil. I added an if(tool_Item.getSelection) to each toolItem Code.
Now it works. Thank You
"Emil Crumhorn" <crumhorn@xxxxxxxxxxxxx> schrieb im Newsbeitrag
news:d4tvb7$3r5$1@xxxxxxxxxxxxxxxxxxx
> Radiobuttons are by default grouped. Just check to see which button has
> the selection to determine what was clicked, like:
>
> public static void main(String args []) {
> Display display = new Display();
> Shell shell = new Shell(display, SWT.SHELL_TRIM);
> shell.setLayout(new FillLayout());
> shell.setSize(150, 150);
>
> // two buttons
> final Button a = new Button(shell, SWT.RADIO);
> a.setText("A");
> a.setData("Button A");
> final Button b = new Button(shell, SWT.RADIO);
> b.setText("B");
> b.setData("Button B");
>
> a.addListener(SWT.Selection, new Listener() {
> public void handleEvent(Event event) {
> System.err.println("I pressed " + (a.getSelection() ? "a" :
> "b"));
> }
> });
>
> shell.open();
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep();
> }
> display.dispose();
> }
>
> Emil
>
>
> "Marco Kohns" <mek@xxxxxxxxxxxx> wrote in message
> news:d4tdk2$b90$1@xxxxxxxxxxxxxxxxxxx
>>I have a toolBar with two toolItems (1 and 2), both with radio-style and
>>SelectionListener(SelectionAdapter)
>>
>> If I press toolItem1 the code inside the SelectionListener will be
>> executed, ok.
>>
>> But if I press toolItem2 the code inside toolItem1s SelectionListener
>> will also be executed again.
>>
>> I've tried to remove the SelectionListener of toolItem1 when the end of
>> the code is reached, but without success. Nothing changes.
>>
>> Thanks For Your Help.
>>
>
>