At 2001-07-13 00:52, you wrote:
>Yes, the NS changes would seem a good idea.
>I noticed that what I had suggested for IE was working by accident, I had
>expected e.returnValue to return the return value, but it doesn't, it
>returns undefined, which was being evaluated as false.
>The only way I found of retrieving the return value in IE was this:
>
>if(e.srcElement.attributes['on'+e.type].nodeValue.indexOf('return
>false')!=-1)
>
>which would return false if value = return false.
>I tried, but couldn't find how to get this value in Mozilla yet.
>Maybe I'm missing something obvious, as I hadn't expected it to be so hard
>to get hold of that value.
>
>I also added this:
>&& e.type!='mousemove'
>to the first if clause, for both IE and NS, otherwise the script is being
>executed constantly as the mouse moves over the page, or a link, and
>onmousemove never needs a return event that I know.
>Also without this check, NS4 started selecting text on the page while
>dragging a dynlayer.
>
>So now the whole thing looks like this:
>mouse.js from line 146:
>
>  // Click on links and form elements
>            if(e && e.target.handleEvent && e.target!=this&&
>e.type!='mousemove'){
>                    evt.browserReturn =
>(e.target.handleEvent(e)==false)?false:evt.browserReturn;
>            }
>     }else
>if(is.ie&&e&&e.srcElement!=this&&e.type!='mousemove'&&e.srcElement.attribute
>s['on'+e.type].nodeValue){
>            evt.browserReturn =
>(e.srcElement.attributes['on'+e.type].nodeValue.indexOf('return
>false')!=-1)?false:evt.browserReturn;
>     }
>     return evt.browserReturn;
>}
>
>(mind line wraps)
>Like this, "return false" in the onclick listener of a hyperlink will cancel
>browser navigation, as it should. This works in IE and NS.
>I don't know if something simpler is possible for IE, and I haven't found
>the values for Mozila yet.
>
>Cheers,
>Richard Bennett
>
>[EMAIL PROTECTED]
>www.richardinfo.com
>(Everything running on, and ported to DynAPI2.53)
>visit the DynAPI homepage (and FAQ) ::
>http://dynapi.sourceforge.net/dynapi/index.php?menu=1
>Browse (and search) the mailinglist here:
>http://www.mail-archive.com/index.php3?hunt=dynapi


The nodeValue was (according to MS) first implemented in IE5.

But I tested what I had before and tweaked it a little bit:

        // Click on links and form elements
        if(e && e.target.handleEvent && e.target!=this && (e.target.handleEvent(e) == 
false))
            evt.browserReturn = false;
    }
    else {
        if(is.ie && e && e.srcElement!=this) // added is.ie so it doesn't run in moz
            evt.browserReturn = e.returnValue;
    }
    if(is.dom && !evt.browserReturn)   // these lines were missing before
        e.preventDefault();
    return evt.browserReturn;
}

(As you may have noticed I didn't include your e.type=="mousemove" test - with it too 
the handleEvent() wouldn't run.)

Now I got it working in IE and Mozilla (0.9.2), but not in NS4 where <A onclick> is 
never run but the click is cancelled anyway (the link isn't followed).

I suspect this fault is an interaction between the draglistener and EventMethod. The 
event listener calls cancelBrowserEvent both on mousedown and mouseup. Another 
observation is that IE and Mozilla call the <A onclick> first, then the 
eventlisteners. In NS4 it is the opposite.

It seems to me that a call to handleEvent is missing, but right now I can't find where 
it would be. Probably at the top of EventMethod. Another possible problem is the fact 
that the API-generated "click" event is invoked while the "mouseup" is. Maybe it's as 
easy as the "click" event changes some value that "mouseup" doesn't want changed (like 
the browserReturn value)?

I used this code to test the variations:

DynAPI.setLibraryPath("/dynapi/src/lib/");
DynAPI.include("dynapi.api.*");
DynAPI.include("dynapi.event.*")
var num=0;
DynAPI.onLoad = function() {
        myLayer = new DynLayer();
        DragEvent.enableDragEvents(myLayer);
        myLayer.setHTML('<A href="misc.html" onclick="alert(1);return 
false">click</A>');
        myListener = new EventListener();
        myListener.onclick = function(e) {
                DynAPI.document.setBgColor("#808080");
                window.status = ++num;
        }
        myLayer.addEventListener(myListener);
        DynAPI.document.addChild(myLayer)
}

That made it simple to test with/without enableDragEvents and returning true or false 
in the <A onclick>. Also indicates in which order the code is executed.

(In NS4: returning false for mousedown disables text selection, but not doing that 
gives you the option to return false for mousemoves which also disables text selection 
- more or less).

/Lunna


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

Reply via email to