<html>
<head>
<title>DynAPI Examples - DynImage</title>
<script language="Javascript" src="../src/dynapi.js"></script>
<script language="Javascript">
DynAPI.setLibraryPath('../src/lib/');
DynAPI.include('dynapi.api.*');
DynAPI.include('dynapi.event.*');
DynAPI.include('dynapi.gui.dynimage.js');
</script>
<script language="Javascript">
DynAPI.onLoad = function() {
        img = new DynImage('../src/lib/dynapi/images/common/arrowup.gif');
        img2 = new DynImage('../src/lib/dynapi/images/common/arrowdown.gif');
        img.moveTo(10,10);
        img2.moveTo(25,10);
        listener = new EventListener()
        listener.onmouseover = function(e) {
                alert(e.getSource());
        }
        img.addEventListener(listener);
        img2.addEventListener(listener);
        DynAPI.document.addChild(img);
        DynAPI.document.addChild(img2);

}
</script>
</head>
<body bgcolor="#ffffff">
</body>
</html>

This should work for any widget as far as I know.  DynImage, List or
anything else.

-- 
Robert Rainwater


On 4/9/2001, 4:26:13 PM EST, Gregor wrote about "[Dynapi-Help] Using a single 
eventlistener for multiple layers":

> I've tried it.  If I leave the DynImage out of the new EventListener
> line:

> listener = new EventListener();
> listener.onclick = function(e)
> {
>    var target = e.getTarget();
>    ...
> }

> image.addEventListener( listener );

> The DynImage does not get any events, in both netscape and ie.  Perhaps
> I am doing something wrong?

> If I do it with:
> listener = new EventListener( image );

> The DynImage gets the event in IE and NS6 but not NS4.75

> Gregor


> Robert Rainwater wrote:
>> 
>> Yes, actually it should work with a DynImage.  Thats the whole point of
>> the widgets is that they inherit from the DynLayer.  So eventlisteners
>> will work on them as well.
>> 
>> --
>> Robert Rainwater
>> 
>> On 4/9/2001, 3:37:21 PM EST, Gregor wrote about "[Dynapi-Help] Using a single 
>eventlistener for multiple layers":
>> 
>> > The answer is no.
>> 
>> > Gregor Brandt wrote:
>> >>
>> >> Does this work with DynImage as well?
>> >>
>> >> Gregor
>> >>
>> >> Robert Rainwater wrote:
>> >> >
>> >> > Just say:
>> >> > listener = new EventListener()
>> >> > listener.onclick = function(e) {
>> >> >    var o = e.getSource();
>> >> >    // o is the dynlayer reference
>> >> > }}
>> >> > layer1.addEventListener(listener)
>> >> > layer2.addEventListener(listener)
>> >> > layer3.addEventListener(listener)
>> >> >
>> >> > When you get the source of the event, you will have the dynlayer
>> >> > reference.
>> >> >
>> >> > --
>> >> > Robert Rainwater
>> >> >
>> >> > On 4/9/2001, 2:09:33 AM EST, Gregor wrote about "[Dynapi-Help] Using a single 
>eventlistener for multiple layers":
>> >> >
>> >> > > I have multiple layers that react identically to a mouse click.  I would
>> >> > > like to write a generic EventListener to handle the clicks for all the
>> >> > > layers.  I can't seem to find a way to do this, is it possible?
>> >> >
>> >> > > Gregor
>> >> >
>> >> > > _______________________________________________
>> >> > > Dynapi-Help mailing list
>> >> > > [EMAIL PROTECTED]
>> >> > > http://lists.sourceforge.net/lists/listinfo/dynapi-help
>> >> >
>> >> > _______________________________________________
>> >> > Dynapi-Help mailing list
>> >> > [EMAIL PROTECTED]
>> >> > http://lists.sourceforge.net/lists/listinfo/dynapi-help
>> >>
>> >> _______________________________________________
>> >> Dynapi-Help mailing list
>> >> [EMAIL PROTECTED]
>> >> http://lists.sourceforge.net/lists/listinfo/dynapi-help
>> 
>> > _______________________________________________
>> > Dynapi-Help mailing list
>> > [EMAIL PROTECTED]
>> > http://lists.sourceforge.net/lists/listinfo/dynapi-help
>> 
>> _______________________________________________
>> Dynapi-Help mailing list
>> [EMAIL PROTECTED]
>> http://lists.sourceforge.net/lists/listinfo/dynapi-help

> _______________________________________________
> Dynapi-Help mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/dynapi-help



_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help

Reply via email to