>
>
> You could do this in script as follows:
>
> <bxml:script>
> function onButtonPress() {
> ...
> }
> </bxml:script>
>
> <PushButton buttonData="Click Me!"
> ButtonPressListener.buttonPressed="onButtonPress()"/>
> <PushButton buttonData="Click Me
> Again!" ButtonPressListener.buttonPressed="onButtonPress()"/>
>
Nice Greg, but imagine a scenario where I can have more than one listener
for the same event. In this case an bxml:id could help to identify it. For
example, if I had 20 buttons, and two different event handlers (one of each
used for 10 buttons).
> FYI, the "ButtonPressListener" qualifier is necessary so BXMLSerializer
> knows which interface defines the handler event.
>
> You could also do this in Java using the listener list directly:
>
> ButtonPressListener buttonPressListener = new ButtonPressListener() {
> public void buttonPressed(Button button) {
> ...
> }
> }
>
> pushButton1.getButtonPressListeners().add(buttonPressListener);
> pushButton2.getButtonPressListeners().add(buttonPressListener);
>
This is the way I'm doing it now, and is good for me, for what I'm using it
for. I just thought that I could do it in a different way, in bxml file. My
scenario is the Memory Game, that I've showed to you. I have 36 buttons, and
only one event listener for then. I could write the only listener needed
using the first example you showed:
<bxml:script>
function onButtonPress() {
...
}
But I thought about the case of multiple common listeners, as I said. Do you
think this could be an enhancement for future releases, or it's not worthy?
--
Luiz Gustavo S. de Souza
http://luizgustavoss.wordpress.com
http://luizgustavoss.blogspot.com
http://twitter.com/lugustso