ToolItem SelectionEvent [message #454805] |
Fri, 29 April 2005 13:38 |
Eclipse User |
|
|
|
Originally posted by: mek.mekistory.de
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.
|
|
|
Re: ToolItem SelectionEvent [message #454834 is a reply to message #454805] |
Fri, 29 April 2005 18:40 |
Emil Crumhorn Messages: 169 Registered: July 2009 |
Senior Member |
|
|
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@mekistory.de> wrote in message
news:d4tdk2$b90$1@news.eclipse.org...
>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.
>
|
|
|
Re: ToolItem SelectionEvent [message #454902 is a reply to message #454834] |
Mon, 02 May 2005 12:56 |
Eclipse User |
|
|
|
Originally posted by: mek.mekistory.de
Thanks Emil. I added an if(tool_Item.getSelection) to each toolItem Code.
Now it works. Thank You
"Emil Crumhorn" <crumhorn@speakeasy.net> schrieb im Newsbeitrag
news:d4tvb7$3r5$1@news.eclipse.org...
> 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@mekistory.de> wrote in message
> news:d4tdk2$b90$1@news.eclipse.org...
>>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.
>>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02767 seconds