incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r529139 - /incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js
Date Mon, 16 Apr 2007 06:13:23 GMT
Author: jmargaris
Date: Sun Apr 15 23:13:22 2007
New Revision: 529139

URL: http://svn.apache.org/viewvc?view=rev&rev=529139
Log:
>From dgennaco: https://issues.apache.org/jira/browse/XAP-377

Modified:
    incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js

Modified: incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js?view=diff&rev=529139&r1=529138&r2=529139
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js Sun Apr 15
23:13:22 2007
@@ -655,9 +655,9 @@
 }
 
 xap.bridges.basic.AbstractWidgetBridge.prototype.getNewAllowedAttributes = function(){
-	return ["id","x","y","width","height","backgroundColor","class",
+	return ["id","x","y","width","height","backgroundColor","backgroundImage","class",
 		"borderWidth","borderColor","borderStyle","margin",
-		"padding","color","textDecoration","fontFamily",
+		"padding","color","cursor","textDecoration","fontFamily",
 		"fontStyle","fontWeight", "fontSize", "textAlign",
 		"popup","tooltip", "focused", "disabled","visible",
 		"onActiveGained","onActiveLost","onDoubleClick","onKeyDown",
@@ -681,6 +681,18 @@
 		}
 }
 
+xap.bridges.basic.AbstractWidgetBridge.prototype.setBackgroundImageAttribute = function(value){
+	if (this.getRootDomNode()){
+        this.getRootDomNode().style.backgroundImage = "url(" + value + ")";
+    }
+}
+
+xap.bridges.basic.AbstractWidgetBridge.prototype.setCursorAttribute = function(value){
+	if (this.getRootDomNode()){ // TODO this can be a url, make sure it is handled in the future
+        this.getRootDomNode().style.cursor = value;
+    }
+}
+
 /** XML attribute set method for "visible" */
 xap.bridges.basic.AbstractWidgetBridge.prototype.setVisibleAttribute = function(value){
 	var rootNode = this.getRootDomNode();
@@ -1239,6 +1251,28 @@
 	}
 }
 
+// Helper function: 
+// Adds a comma-delimited list of modifiers to the mods property of the client 
+// event.
+xap.bridges.basic.AbstractWidgetBridge.prototype._addKeyMods = function( event, htmlEvent){
+    if (!htmlEvent || !event) {
+        return;
+    }
+	event.mods = "";
+    var comma = "";
+    if (htmlEvent.shiftKey==1) {
+        event.mods += "Shift";
+        comma = ",";
+    }
+    if (htmlEvent.ctrlKey==1) {
+        event.mods += comma + "Ctrl";
+        comma = ","
+    }
+    if (htmlEvent.altKey==1) {
+        event.mods += comma + "Alt";
+    }
+}
+
 xap.bridges.basic.AbstractWidgetBridge.prototype.fireMouseEvent = function( eventName, htmlEvent){
     // optimization, check whether there is an event handler registered and exit fast first
     if (!this.getElement().getAttribute(eventName)) {
@@ -1252,10 +1286,12 @@
 	clientEvent.clickX = htmlEvent.layerX;
 	clientEvent.clickY = htmlEvent.layerY;
 	clientEvent.buttonNumber = htmlEvent.button;
+	this._addKeyMods(clientEvent, htmlEvent);
+	
 	this.fireEvent(eventName,null,null,clientEvent);
 	//IMPORTANT button number is 0-2 based, not 1-3?
 	//depends on browser, need to fix this up...
-	//IMPORTANT mods, consumed, cancel?
+	//IMPORTANT consumed, cancel?
 }
 
 xap.bridges.basic.AbstractWidgetBridge.prototype.fireKeyEvent = function( eventName, htmlEvent){
@@ -1273,8 +1309,10 @@
 	var character = String.fromCharCode(code);
 	clientEvent.keyCode = code;
 	clientEvent.keyChar = character;
+	this._addKeyMods(clientEvent, htmlEvent);
+	
 	this.fireEvent(eventName,null,null,clientEvent);
-	//IMPORTANT mods, consumed, cancel?
+	//IMPORTANT consumed, cancel?
 }
 
 // Mapper to specialized attribute removal methods:



Mime
View raw message