|
|
Re: SingleSourcing - Replacement of Widget.notifyListeners [message #125354 is a reply to message #125322] |
Tue, 17 March 2009 17:28 |
Stefan Hansel Messages: 103 Registered: July 2009 |
Senior Member |
|
|
Dies ist eine mehrteilige Nachricht im MIME-Format.
--=_alternative 0060029BC125757C_=
Content-Type: text/plain; charset="US-ASCII"
>> why don't you have your listener code delegate to, say updateSeletion()
I'm trying to write a replacement for javax.swing.ButtonGroup
(as in SWT radioButton.setSelection(true) doesn't deselect the other
radio-buttons)
As I don't know if anyone else has listeners on the radio-buttons
(actually I even DO know that some have :D), I have to ensure, that proper
events are fired.
>> however, Widget#notifyListeners() is in CVS HEAD and will be available
in 1.2 M6
Good news, at least I can comment my current hack:
Listener[] listeners = radioButton.getListeners(SWT.Selection);
for (int j = 0; j < listeners.length; j++) {
Listener listener = listeners[j];
Event selectionEvent = new Event();
selectionEvent.type = SWT.Selection;
selectionEvent.widget = radioButton;
listener.handleEvent(selectionEvent);
}
--=_alternative 0060029BC125757C_=
Content-Type: text/html; charset="US-ASCII"
<br><tt><font size=2>>> why don't you have your listener code delegate
to, say updateSeletion()</font></tt>
<br><tt><font size=2>I'm trying to write a replacement for javax.swing.ButtonGroup
</font></tt>
<br><tt><font size=2>(as in SWT radioButton.setSelection(true) doesn't
deselect the other radio-buttons)</font></tt>
<br>
<br><tt><font size=2>As I don't know if anyone else has listeners on the
radio-buttons (actually I even DO know that some have :D), I have to ensure,
that proper events are fired.</font></tt>
<br>
<br><tt><font size=2>>> however, Widget#notifyListeners() is in CVS
HEAD and will be available in 1.2 M6</font></tt>
<br><tt><font size=2>Good news, at least I can comment my current hack:</font></tt>
<br>
<br><font size=2 face="Courier New">Listener[] listeners = radioButton.<b>getListeners</b>(SWT.Selection);</font>
<br><font size=2 color=#820040 face="Courier New"><b>for</b></font><font size=2 face="Courier New">
(</font><font size=2 color=#820040 face="Courier New"><b>int</b></font><font size=2 face="Courier New">
j = 0; j < listeners.</font><font size=2 color=#0021bf face="Courier New">length</font><font size=2 face="Courier New">;
j++) {</font>
<br><font size=2 face="Courier New"> Listener
listener = listeners[j];</font>
<br><font size=2 face="Courier New"> Event
selectionEvent = </font><font size=2 color=#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier New">
<b>Event</b>();</font>
<br><font size=2 face="Courier New"> selectionEvent.</font><font size=2 color=#0021bf face="Courier New">type</font><font size=2 face="Courier New">
= SWT.Selection;</font>
<br><font size=2 face="Courier New"> selectionEvent.</font><font size=2 color=#0021bf face="Courier New">widget</font><font size=2 face="Courier New">
= radioButton;</font>
<br><font size=2 face="Courier New"> listener.</font><font size=2 color=#008080 face="Courier New">handleEvent</font><font size=2 face="Courier New">(selectionEvent);</font>
<br><font size=2 face="Courier New">}</font>
<br>
<br>
<br>
<br>
<br>
--=_alternative 0060029BC125757C_=--
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03901 seconds