Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsButton loses selection event after disabled it
https://www.eclipse.org/forums/index.php/mv/msg/156530/493378/#msg_493378
When I create a button and its relative event on click like this:
Button button = new Button(buttonBox, SWT.NONE);
button.setText("Click me");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
// do something after click
}
});
works fine. Anyway, if it have been disabled somewhere in the code by:
button.setEnabled(false);
and then re-enabled with:
button.setEnabled(true);
clicking on it has no more effect. It looks like button has lost the listener.
Is it normal? Do I need to re-add selection event?
Thanks,
Julio]]>antonio2009-10-25T14:39:13-00:00Re: Button loses selection event after disabled it
https://www.eclipse.org/forums/index.php/mv/msg/156530/493381/#msg_493381
> Anyway, if it have been disabled somewhere in the code by:
>
> button.setEnabled(false);
>
> and then re-enabled with:
>
> button.setEnabled(true);
>
> clicking on it has no more effect. It looks like button has lost the
> listener. Is it normal? Do I need to re-add selection event?
This works fine for me on Linux/gtk+. My test code is as follows:
final Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(200, 50);
shell.setLayout(new FillLayout());
final Button b1 = new Button(shell, SWT.PUSH);
b1.setText("1");
final Button b2 = new Button(shell, SWT.PUSH);
b2.setText("2");
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
shell.dispose();
display.dispose();
Regards,
Remy]]>Remy Suen2009-10-25T14:44:10-00:00Re: Button loses selection event after disabled it
https://www.eclipse.org/forums/index.php/mv/msg/156530/493388/#msg_493388
thanks for reply.
I tested ur code but it doesn't work for me (same problem).
When I launch it and click '2' button then "Pushed" is displayed on console. Anyway, after pressing '1' that disable '2' and finally re-enabling it after second click, '2' button doesn't work anymore, I mean everytime click it, "Pushed" is not more displayed.
I'm using SWT 3.3 on Linux/Gtk+
Upgrading SWT version is a real problem for me, cos I'm using Maven 2 and there is not a public repository hosting 3.4/3.5 version for SWT AFAIK
Julio]]>antonio2009-10-25T16:24:08-00:00Re: Button loses selection event after disabled it
https://www.eclipse.org/forums/index.php/mv/msg/156530/493390/#msg_493390
> I'm using SWT 3.3 on Linux/Gtk+
3.3 is no longer supported. You should at least download Eclipse 3.5 and
try SWT 3.5 to see if it works for you. That would at least help figure
out whether it is your system's problem or not.
Regards,
Remy]]>Remy Suen2009-10-25T16:49:19-00:00Re: Button loses selection event after disabled it
https://www.eclipse.org/forums/index.php/mv/msg/156530/493406/#msg_493406
> Hi Remy,
>
> thanks for reply.
>
> I tested ur code but it doesn't work for me (same problem).
> When I launch it and click '2' button then "Pushed" is displayed on
> console. Anyway, after pressing '1' that disable '2' and finally
> re-enabling it after second click, '2' button doesn't work anymore, I
> mean everytime click it, "Pushed" is not more displayed.
>
> I'm using SWT 3.3 on Linux/Gtk+
>
> Upgrading SWT version is a real problem for me, cos I'm using Maven 2
> and there is not a public repository hosting 3.4/3.5 version for SWT AFAIK
>
> Julio
You may be running into an incompatibility between SWT and the latest
version of Gtk.
See if the workaround in this bug fixes the problem.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=291257]]>David Wegener2009-10-26T01:26:55-00:00Re: Button loses selection event after disabled it
https://www.eclipse.org/forums/index.php/mv/msg/156530/495274/#msg_495274
that fix doesn't work for me. I'm using Ubuntu 9.10 Karmic.
Anyway that problem seems to be present in SWT 3.5.1 too.
any hint?
thanks,
julio]]>antonio2009-11-04T13:08:21-00:00Re: Button loses selection event after disabled it
https://www.eclipse.org/forums/index.php/mv/msg/156530/495327/#msg_495327
Using Remy's snippet I see that this problem is fixed in the eclipse 3.6
stream but still happens in the latest 3.5.2 build. However I can make it
work in eclipse 3.5.2 by setting environment variable GDK_NATIVE_WINDOWS to
1 before running. When this variable is set GTK 2.18 reverts to some
specific pre-GTK-2.18 behaviours that SWT was dependent on. This may help
you with using eclipse 3.3 as well.
HTH,
Grant
"antonio" <antongiulio05@gmail.com> wrote in message
news:hcruc7$nol$1@build.eclipse.org...
> Hi,
>
> that fix doesn't work for me. I'm using Ubuntu 9.10 Karmic.
>
> Anyway that problem seems to be present in SWT 3.5.1 too.
>
> any hint?
>
> thanks,
> julio]]>Grant Gayed2009-11-04T15:20:05-00:00Re: Button loses selection event after disabled it
https://www.eclipse.org/forums/index.php/mv/msg/156530/495511/#msg_495511
I have experienced that issue with a lot of buttons in eclipse 3.4.2 and 3.5.1 with and without GDK_NATIVE_WINDOWS set. Anyway I re-updated Ubuntu 9.10 (last time was 2 weeks ago), and set it works now (same for my application using SWT 3.3).