[xinf] DOM Events?
iiley
iiley.chen at gmail.com
Thu Jun 22 20:59:04 CEST 2006
Supper cool, i like the Nicolas way very much, now, i see the real big
power of haXe. ;] coool~~~
But the
public function onMouseDown( e:MouseEvent ) :Void {
...
}
...
addEventListener( MouseEvent.MOUSE_DOWN, new
CastingEventListener<MouseEvent>( onMouseDown ) );
...
Looks good too in my opinion.
In my opinion both the two way avoid class explosion of
ListenerInterfaces(like ActionListener, MouseListener,
ComponentListener, many many listener interface in Java Swing), but
there are still many Event classes too, i'm new to haXe, just
wondering is there a way avoid Event class explosion instead of
handler functions like:
public function new() {
var b = new Button();
b.onRefresh.addListener(this);
b.onClick.addListener(new Listener(handleClick));
}
function handleClick( source:Button, x:Number, y:Number) {
// TODO
}
public function handleEvent( source:Button, rect : { x : Int, y
: Int, width : Int, height : Int }) {
// TODO
}
This avoid to define many sub-Event classes, Is it fantastic?
2006/6/23, Nicolas Cannasse <ncannasse at motion-twin.com>:
> The important part is what the end-user will have to deal with.
>
> This show for example how to register events :
>
> > public function new() {
> > var b = new Button();
> > // we have an handleEvent (must be public)
> > b.onRefresh.addListener(this);
> > // create and adaptor
> > b.onClick.addListener(new Listener(handleClick));
> > }
> >
> > function handleClick( evt : ClickEvent ) {
> > // TODO
> > }
> >
> > public function handleEvent( evt : RefreshEvent ) {
> > // TODO
> > }
>
> Of course, everything is strictly typed so no error can occur.
>
> Nicolas
>
> --
> xinf is not flash
> http://xinf.org/
>
--
iiley
AsWing http://www.aswing.org
Blog http://spaces.msn.com/members/iiley/
More information about the xinf
mailing list