Give AutoComplete teh snappy
[potlatch2.git] / net / systemeD / controls / AutoComplete.as
index 99d9e36a1a2baf1ed8971e6969de743d05ad0ad3..ea8827b132c52048df53cc318db4a43ff4a4eb57 100644 (file)
@@ -17,6 +17,7 @@ package net.systemeD.controls {
        import flash.events.MouseEvent;
        import flash.net.SharedObject;
        import flash.ui.Keyboard;
+       import flash.utils.*;
        import mx.core.UIComponent;
        import mx.controls.ComboBox;
        import mx.controls.DataGrid;
@@ -81,6 +82,7 @@ package net.systemeD.controls {
                        setStyle("cornerRadius",0);
                        setStyle("paddingLeft",0);
                        setStyle("paddingRight",0);
+                       setStyle("openDuration",0);
                        rowCount = 7;
                        
                        if (maxChars) textInput.maxChars=maxChars;
@@ -96,6 +98,7 @@ package net.systemeD.controls {
                private var showingDropdown:Boolean=false;
                private var tempCollection:Object;
                private var dropdownClosed:Boolean=true;
+               private var dropdownTimer:uint;
                public var maxChars:uint=0;
 
                //--------------------------------------------------------------------------
@@ -231,12 +234,18 @@ package net.systemeD.controls {
 
                        if (showDropdown && !dropdown.visible) {
                                // controls the open duration of the dropdown
-                               super.open();
                                showDropdown = false;
-                               showingDropdown = true;
-                               dropdownClosed = false;
+                               clearTimeout(dropdownTimer);
+                               dropdownTimer=setTimeout(openDropdown,100);
                        }
                }
+
+               private function openDropdown():void {
+                       clearTimeout(dropdownTimer);
+                       super.open();
+                       showingDropdown = true;
+                       dropdownClosed = false;
+               }
        
                override protected function keyDownHandler(event:KeyboardEvent):void {
                        super.keyDownHandler(event);