incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r463823 - in /incubator/xap/trunk/WebContent/examples/widgets: AttributeTester.js textField.xal
Date Fri, 13 Oct 2006 20:58:16 GMT
Author: mturyn
Date: Fri Oct 13 13:58:15 2006
New Revision: 463823

URL: http://svn.apache.org/viewvc?view=rev&rev=463823
Log:
Added a status line and method printing to it---opening an "alert" box would take focus from
the textfield, triggering an "onEdit" event, whenever a key were pressed, making it hard to
debug "onTextChange".

Modified:
    incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js
    incubator/xap/trunk/WebContent/examples/widgets/textField.xal

Modified: incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js?view=diff&rev=463823&r1=463822&r2=463823
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js Fri Oct 13 13:58:15
2006
@@ -24,20 +24,39 @@
 // Don't want to trigger an additional onEdit by popping up
 // an alert() box, which would make the textfield lose focus---so write it here
 AttributeTester.prototype.reportTextFieldEventWithoutAlert = function(event){
-	var sourceElement = event.source ;
-	var charCode = event.originalEvent.keyCode ;
-//	if (  charCode < 65 || charCode>123 ){
-//	    return ;
-//	}
-	if( ! event.originalEvent.shiftKey ){
-		charCode += 32 ;
+	var evt = event.originalEvent ;
+	var code ;
+	if (evt.keyCode){
+		// moz
+		code = evt.keyCode;
+	}	else if (	evt.which){
+		code = evt.which;
+	}
+	
+	
+	var pressed = "";
+	if( code<65 || code>91){
+		pressed = "<non-alphabetic>"
+	} else {
+		if(!evt.shiftKey){
+			code += 32 ;
+		}
+		pressed = "'"+String.fromCharCode(code) +"'" ;
 	}
-	var charr = String.fromCharCode(charCode);	
 	
-	sourceElement.setAttribute("text","" 
-			//+ sourceElement.getAttribute("text")
-			+ event.event+"[" + charr +"]; "
-									) ;
+	var sourceElement = event.source ;
+	
+	var statusText =  (""+event).replace(/[\r\n]/g,";") ;
+
+	var statusLineElement = sourceElement.getOwnerDocument().getElementById("status") ;
+	
+	if( !statusLineElement ){
+		return ;
+	}	
+	var statusLineHandler 
+		= event.session.getUiDocumentHandler().getHandlerForElement( statusLineElement );				
+	statusLineHandler.setTextAttribute( "[" +code+":"+ pressed+"]:   " +statusText ) ;
+
 }
 
 

Modified: incubator/xap/trunk/WebContent/examples/widgets/textField.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/textField.xal?view=diff&rev=463823&r1=463822&r2=463823
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/textField.xal (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/textField.xal Fri Oct 13 13:58:15 2006
@@ -17,6 +17,16 @@
 		onTextChange="mco:attributeSetter.reportTextFieldEventWithoutAlert(event)"
 		/>
 		
+		<xal:label text="Alphabetic keyboard events:" id="statusLabel" 
+				color="darkred"  height="30px"  width="200px"
+				fontSize="9pt" alignVertical="bottom" fontWeight="bold"	
+		/>		
+		<xal:label text="" id="status" 
+				color="darkred"  height="30px" 
+				fontSize="9pt" alignVertical="top"	
+		/>
+
+		
 		
 		<!-- textField specific properties -->
 		<xal:button width="200px" height="25px" 



Mime
View raw message