incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r482543 - /incubator/xap/trunk/src/xap/widgets/ListBox.js
Date Tue, 05 Dec 2006 07:52:04 GMT
Author: mturyn
Date: Mon Dec  4 23:52:03 2006
New Revision: 482543

URL: http://svn.apache.org/viewvc?view=rev&rev=482543
Log:
Needed to add a few methods here for the editableComboBox peer; no old ones affected.

Modified:
    incubator/xap/trunk/src/xap/widgets/ListBox.js

Modified: incubator/xap/trunk/src/xap/widgets/ListBox.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/widgets/ListBox.js?view=diff&rev=482543&r1=482542&r2=482543
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/ListBox.js (original)
+++ incubator/xap/trunk/src/xap/widgets/ListBox.js Mon Dec  4 23:52:03 2006
@@ -17,10 +17,12 @@
 dojo.lang.extend(xap.widgets.ListBox, {
 // If size==1, get a combo box, which we don't want, so
 // start with size 2, increment if necessary as we add children:
-		templateString: '<select dojoAttachPoint="select" dojoAttachEvent="onkeyup;onchange;onmouseout"
size="2"></select>',
+//(Note:onkeydown, onblur so far is only needed if this is a combobox interior.)
+		templateString: '<select dojoAttachPoint="select" dojoAttachEvent="onkeyup;onchange;onmouseout;onkeydown;onblur"
size="2"></select>',
 		templateCssPath: null,
 		widgetType: "ListBox",
 		isContainer: true,
+		trueSize:0,
 		addChild: function(child) { /* elementListItem */
 			
 			this.select.appendChild(child.domNode); 
@@ -46,8 +48,60 @@
 			this.select.onchange = function() {
 				obj && obj[fn] && obj[fn](param);
 			}
-		}
+		},
+		
+		maxHeight:function(){
+		// Find the max height of the select box
+			var node = this.domNode ;
+			var height = 0 ;
+			var optionNode  = node.firstChild ;
+			while( optionNode ){
+				height = optionNode.clientHeight ;
+				optionNode = optionNode.nextSibling ;
+			}
+			return height ;
+		},
+		
+		firstOptionHeight:function(){
+		// Find the height of the top part of the select box
+		// or the select node itself, or the intended height of the first option:
+			var node = this.domNode ;
+			var height = node.clientHeight ;
+			var optionNode  = node.firstChild ;
+			if( optionNode ){
+				height = optionNode.clientHeight ;
+				// The option might invisible, in which case it
+				// doesn't have a clientHeight, but it might have a style promising
+				// it's future height: 
+				var heightString = optionNode.style.height.replace(/px/,"") ;
+				if( heightString.match(/^ *[0-9]+ *$/)){
+					var styleHeight = parseInt(heightString ) ;
+					if( styleHeight != "NaN" ){
+						height = Math.max( height, styleHeight ) ;
+					}
+				}
+			}
+			return height ;				
+		},
+			
+		numberOfOptions:function(){
+			return this.select.options.length ;			
+		}		
+
 		
 		
 	}
-);
\ No newline at end of file
+);
+
+
+// Maybe use this later:
+	// Move to next option beginning with this key's char, if it's a letter:
+//	var select = this.select ;
+//	for( var ii=select.selectedIndex+1; ii<select.options.length; ++ii){
+//		if (key == select.options[ii].text.charAt(0) ){
+//			select.selectedIndex = ii ;
+//			break ;
+//		}
+//	}	
+
+



Mime
View raw message