[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    Bug#20290: no crash in KDE 2.2, but Mouse Event handler (DOM, KJS) doesn't work, testcase included
From:       Vadim Plessky <lucy-ples () mtu-net ! ru>
Date:       2001-10-31 20:05:38
[Download RAW message or body]

On Wednesday 31 October 2001 15:09, David Faure wrote:
|   On Mercredi 31 Octobre 2001 18:12, Vadim Plessky wrote:
|   > alert ("OrigWidth = "+OrigWidth+" OrigHeight= "+ OrigHeight+"\n
|   > WindowLeftEdge= "+WindowLeftEdge+" WindowTopEdge= "+WindowTopEdge);
|
|   This statement has a string constant going over two lines, which leads to
| a parse error.

AFAIK construction above is legal ('\n' applies to alert box content - alert 
box's text has *two lines* than)
and it works in this way in MS IE and Mozilla

|   Ah, maybe this is just a copy-n-paste problem... please attach testfiles
| next time ;)

attached now.
// and it was attached to original Bug Report, but seems it's not esy to 
extract attachament from bugs database.
|
|   Ok, after fixing several of such newline problems.....
|   .. adding debug output....
|
|   --> (1)s=<BR>clientX= 298, clientY = 135<BR> x_Offset= undefined,
| y_Offset = undefined<BR>screenX= 304, screenY = 321<BR>e.button= 0<BR> 
| e.type= mouseover<BR> e.x= 298 e.y= 135<BR>document.body.scrollLeft = -10
| .scrollTop= -10 --> ClickElement=undefined
|
|   There. This bug is in fact
|   "event.srcElement" isn't implemented.
|
|   If you replace
|   var ClickElement = /*(IE) ? e.srcElement :*/ e.target;
|   with
|   var ClickElement = e.target;
|   in the testcase, it starts working.

thanks for tip, I wil try it! :-)

|
|   I'll have to lookup the definition of srcElement (yet another IE
| extension I guess!), no time right now.

yes, another MS extension. :-))
But Mozilla is also far away from standard (and AFAIK mouse events are 
finalized only in DOM3, which is still not recommendation, just working 
draft...)
|
|   David.
|   _______________________________________________
|   Konq-bugs mailing list
|   Konq-bugs@mail.kde.org
|   http://mail.kde.org/mailman/listinfo/konq-bugs

-- 

Vadim Plessky
http://kde2.newmail.ru  (English)
33 Window Decorations and 6 Widget Styles for KDE
http://kde2.newmail.ru/kde_themes.html
KDE mini-Themes
http://kde2.newmail.ru/themes/

["mouse_Events_IE_NN.html" (text/html)]

<HTML>
  <HEAD>
    <TITLE>Mouse (Event) Test</TITLE>
<STYLE TYPE="text/css"> 
 <!--
 .mypanelclass
 	{
 		border-width: 2px;
 		border-style: solid;
 		border-color: #000000;
 		font: 12px arial,helvetica;
 		background: #ffffff;
 		z-index: 10;
 		layer-background-color: #ffffff;
 	}
 
 	#mypanel {
 		position:absolute;
 		top:300px;
 		left:80px;
 		width:300px;
 		height:200px;
 		border: medium solid Red;
 		padding: 0px;
 		overflow : scroll;
 	}
 -->
 </STYLE> 

<SCRIPT LANGUAGE="JavaScript">
  var  DOM = (document.getElementById) ? true : false;
  var  NN4 = (document.layers) ? true : false;
  var   IE = (document.all) ? true : false;
  var  IE4 = IE && !DOM;
  var  Mac = (navigator.appVersion.indexOf("Mac") != -1);
  var IE4Mac = IE4 && Mac;
  var IE5Win = IE && !Mac;
  var NS6 = (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));

  // for Netscape Navigator 4 compatibility
  var oldtext="";
  var debug = true;
  var s=""; // temporary string
  
  if (debug)
    alert("DOM= "+DOM+"\n IE="+IE+"\n NN4= "+NN4);

function InitParams()
{ 
	if( IE)
	{
	var WindowLeftEdge = document.body.scrollLeft;
	var WindowTopEdge  = document.body.scrollTop;

	  OrigWidth = document.body.clientWidth; 
	  OrigHeight = document.body.clientHeight; 
	}
	else
	{ 
/*
    var ExtraSpace     = 10;
	var WindowLeftEdge = (IE) ? document.body.scrollLeft   : window.pageXOffset;
	var WindowTopEdge  = (IE) ? document.body.scrollTop    : window.pageYOffset;
	var WindowWidth    = (IE) ? document.body.clientWidth  : window.innerWidth;
	var WindowHeight   = (IE) ? document.body.clientHeight : window.innerHeight;
	var WindowRightEdge  = (WindowLeftEdge + WindowWidth) - ExtraSpace;
	var WindowBottomEdge = (WindowTopEdge + WindowHeight) - ExtraSpace;
*/
	var WindowLeftEdge = window.pageXOffset;
	var WindowTopEdge  = window.pageYOffset;

	 OrigWidth  = window.innerWidth;
	 OrigHeight = window.innerHeight;
	};
alert ("OrigWidth = "+OrigWidth+" OrigHeight= "+ OrigHeight+"\n WindowLeftEdge= \
"+WindowLeftEdge+" WindowTopEdge= "+WindowTopEdge);

}
 
  var panel;
  
 function ClickHandler(e)
 {
/*   Here are parameters DynAPI looking for:
   // events.js
 	var pageX, pageY, x, y;
	pageX= IE? e.x+document.body.scrollLeft: e.pageX-window.pageXOffset
	pageY= IE? e.y+document.body.scrollTop:e.pageY-window.pageYOffset
	
	x= IE? e.offsetX:e.layerX
	y= IE? e.offsetY:e.layerY
	var b= IE? e.button: e.which
	
	and, in line 103: (events.js)
	var which=(is.ie||is.ns5)?e.button:e.which
  
	var alt,ctrl,shft
	if ( IE || NS5 ){
		alt=(e.altKey||e.altLeft)?true:false 
		ctrl=(e.ctrlKey||e.ctrlLeft)?true:false 
		shft=(e.shiftKey||e.shiftLeft)?true:false 
	}
	if ( NN4 ){
		var m=e.modifiers
		alt=(m==1||m==3||m==5||m==7)?true:false	
		ctrl=(m==2||m==3||m==6||m==7)?true:false	
		shft=(m==4||m==5||m==6||m==7)?true:false	
	}
	**********************************************
	Mozilla / NS6
	e.button 	Button pressed
	= 65535		no button was pressed (mouseOver)
	= 1			Left
	= 2			Middle
	= 3 		Right
	
	Netscape navigator 4.x
	e.which		Button Pressed
	= 0			no button was pressed (mouseOver)
	= 1			Left
 */
 
  if(IE) e = event;
  
  x_Offset = (IE) ? e.offsetX : e.layerX;
  y_Offset = (IE) ? e.offsetY : e.layerY;
  
   // document.write("<BR>Mouse clicked");
   //   document.write("<BR>clientX,clientY = " +e.clientX, e.clientY);
    
	if (NN4) 
	{
	//   if (e.type != "click") return true;
 
	//  alert( "Clicked in Netscape 4.x (doesn't work onMouseOver H2, only A HREF)");
	  if (s=="") s= "Clicked in Netscape 4.x (doesn't work onMouseOver H2, only A \
HREF)";  else
	    s = "<BR>X (e.pageX)= " +e.pageX+", Y (e.pageY)= "+e.pageY;
	  
	  s = s+"<BR> x_Offset= " +x_Offset+", y_Offset = "+y_Offset;
	  s = s+"<BR>button (e.which)= "+e.which;
	  s = s+"<BR>  e.type "+e.type;
	  s = s+"<BR> window.pageXOffset = "+window.pageXOffset+" window.pageYOffset= \
"+window.pageYOffset;  } 
	else
{
	s= "<BR>clientX= " +e.clientX+", clientY = "+e.clientY;
	s= s+"<BR> x_Offset= " +x_Offset+", y_Offset = "+y_Offset;
	s= s+"<BR>screenX= " +e.screenX+", screenY = "+e.screenY;
	//  1 == Left Button, 3 = Right Button, 2 == Middle Button (Mozilla)
	s = s+"<BR>e.button= "+e.button;
	s = s+"<BR>  e.type= "+e.type;
	
	if (IE)
	{
	  s = s+ "<BR> e.x= "+e.x+" e.y= "+e.y;
	  s = s+ "<BR>document.body.scrollLeft = "+document.body.scrollLeft+" .scrollTop= \
"+document.body.scrollTop;  }
	else
	 {
	   // well, it is not IE and not NN 4.7x
	   //  so, what it is? May be, Mozilla?
	   s = s+"<BR> window.pageXOffset = "+window.pageXOffset+" window.pageYOffset= \
"+window.pageYOffset;  s = s+ "<BR>X (e.pageX)= " +e.pageX+", Y (e.pageY)= "+e.pageY;
	 
	 }
	pageX= IE? e.x+document.body.scrollLeft: e.pageX-window.pageXOffset;
	pageY= IE? e.y+document.body.scrollTop: e.pageY-window.pageYOffset;
	
	var ClickElement = (IE) ? e.srcElement : e.target;
	
	if(NS6) 
	{
		while(ClickElement.tagName==null)
		{
			ClickElement = ClickElement.parentNode;
		}
	}	
		s = s+	"<BR>Event Element.ID ="+ClickElement.id;
		s= s+ "<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     Element.tagName \
="+ClickElement.tagName;  
}
  //   alert("clientX,clientY = " +e.clientX+","+e.clientY);
 //     writeToID( s, "mypanel");
   AddToID( s, "mypanel");
 }
 
function AddToID(text,id)
{
  var previous;
   
	if (DOM)
	{
		x = document.getElementById(id);
		previous = x.innerHTML; 
		x.innerHTML = previous+'\n'+text;
	}
	else if (IE4)
	{
		x = document.all[id];
		previous = x.innerHTML; 
		x.innerHTML = previous+'\n'+text;
	}
	else if (NN4)
	{
		x = document.layers[id];
	
	 //  alert ("Netscape 4 - Add text to Layer; id="+id );
	
	/*
	 	text2 = '<P CLASS="testclass">' + text + '</P>;';
	  */
		oldtext = oldtext+text;
	//	alert( "oldtext="+oldtext);
		  
		text2 = '<P CLASS="mypanelclass">' + oldtext + '</P>;';
		
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

function writeToID(text,id)
{
	if (DOM)
	{
		x = document.getElementById(id);
		x.innerHTML = text;
	}
	else if (IE4)
	{
		x = document.all[id];
		x.innerHTML = text;
	}
	else if (NN4)
	{
		x = document.layers[id];
		text2 = '<P CLASS="mypanelclass">' + text + '</P>;';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

</SCRIPT>
  
  </HEAD>
  
  <!--  calculate OrigWidth and OrigHeight, hook required for MS IE only  
  -->
  <BODY onLoad="InitParams()">
    <H2>Mouse Events (onMouseOver, onMouseClick)</H2>
	<H2 ID="Tag no 2, with Click" onClick="ClickHandler(event)" \
onMouseDown="ClickHandler(event)"  onMouseUp="ClickHandler(event)">Click mouse when \
it is inside this tag</H2>  <TABLE WIDTH="300px" BORDER="1" CELLSPACING="5" \
CELLPADDING="5" BGCOLOR="Gray">  <TR>
	  <TD>
<!-- 
	<H2 ID="Tag no 3, MouseOver" onMouseOver="ClickHandler(event) \
onClick="ClickHandler(event)" onMouseOut="ClickHandler(event)">  Move \
                <I>mouseOver</I> this tag, Click it or just move mouseOut</H2>
     --> 
	<H2 ID="Tag no 3, with 3 event Handlers" onMouseOver="ClickHandler(event)" \
onClick="ClickHandler(event)"   onMouseOut="ClickHandler(event)">
	Move <I>mouseOver</I> this tag, Click it or just move mouseOut</H2>

	  </TD>
	</TR>
	</TABLE>
<!--	
<P><A HREF="OldBrowsersGoesHere.html" onMouseOver="popUp('HM_Menu3',event)" 
onMouseOut="popDown('HM_Menu3')" onClick="return false">A HREF OnMouseOver</A>
</P>
-->	
<P><A HREF="OldBrowsersGoesHere.html" onMouseOver="ClickHandler(event)" 
onMouseOut="return false" onClick="return false">A HREF OnMouseOver</A>
</P>
<P><A HREF="OldBrowsersGoesHere.html" onMouseOver="return false" 
onMouseOut="return false" onClick="ClickHandler(event); return false">A HREF \
onClick</A> </P>
 
  <DIV CLASS="mypanelclass" ID="mypanel">
  Mouse events are listed here:
  </DIV>
<!--  for Netscape 4.x compatibility  -->
    
<SCRIPT LANGUAGE="JavaScript">
//  panel = document.getElementById("mypanel");
   if (NN4) AddToID( "Change to Netscape", "mypanel");
   
</SCRIPT>
  
</BODY>
</HTML>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic