From: Richard B. <ric...@sk...> - 2001-07-14 09:08:37
|
This doesn't look correct to me, if you test for the value of e.returnValue; in IE5.5, it will always return "undefined", which will of course seem to work, but it is actually always returning false. Also, shouldn't the dom test be inside the same "else" clause as the ie test? And using IE5+ wouldn't it first execute the IE clause, and then the dom one? I'm surprised the mousemove test affected handleEvent, as it seemed to work ok here, and seemed to resolve some annoying textselection problems especially in NS4, I'll give it a try with your sample code. If you use this sample code, you'll see the textselection problem in NS4, as you drag the blue layer: DynAPI.onLoad = function() { myLayer = new DynLayer('myLayer',0,50,50,50,'blue') DragEvent.setDragBoundary(myLayer) DragEvent.enableDragEvents(myLayer) DynAPI.document.addChild(myLayer) var clk=new EventListener() clk.onclick=function(e) { alert('hi') } myLayer.addEventListener(clk) } </script> </head> <body bgcolor="#000000"> <a href="Message: Click this to test" onclick="status='woot!';return true;">stuff</a> </body> </html> Richard. > // 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 > Dyn...@li... > http://lists.sourceforge.net/lists/listinfo/dynapi-help > |