Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added fixed PopUpAnchor that correctly repositions itself

  • Loading branch information...
commit e0a4d13cf6177de54912f2c48a64eda7306692d1 1 parent 6096ffd
JabbyPanda authored
View
3  .actionScriptProperties
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<actionScriptProperties analytics="false" mainApplicationPath="org/jabbypanda/samples/SampleAutoComplete.mxml" projectUUID="3a8262bc-8adf-4648-a6e9-2c15140fe630" version="6">
+<actionScriptProperties analytics="false" mainApplicationPath="org/jabbypanda/samples/SampleAutoComplete.mxml" projectUUID="3a8262bc-8adf-4648-a6e9-2c15140fe630" version="7">
<compiler additionalCompilerArguments="-locale en_US" autoRSLOrdering="true" copyDependentFiles="true" flexSDK="Flex 4.1.0" fteInMXComponents="false" generateAccessible="true" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersionCheck="true" includeNetmonSwc="false" outputFolderPath="bin-debug" sourceFolderPath="src" strict="true" targetPlayerVersion="0.0.0" useApolloConfig="false" useDebugRSLSwfs="true" verifyDigests="true" warn="true">
<compilerSourcePath/>
<libraryPath defaultLinkType="0">
@@ -14,4 +14,5 @@
<applications/>
<modules/>
<buildCSSFiles/>
+ <flashCatalyst validateFlashCatalystCompatibility="false"/>
</actionScriptProperties>
View
2  .flexLibProperties
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<flexLibProperties includeAllClasses="true" version="3">
+<flexLibProperties includeAllClasses="true" useMultiPlatformConfig="false" version="3">
<includeClasses/>
<includeResources/>
<namespaceManifests>
View
4 .settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,3 @@
-#Mon Aug 16 16:06:00 EEST 2010
+#Tue Dec 28 16:34:27 EET 2010
eclipse.preferences.version=1
-encoding/<project>=utf-8
+encoding/<project>=UTF-8
View
BIN  bin/InputAssist-0.14.swc
Binary file not shown
View
3  src/com/jabbypanda/controls/HighlightItemList.as
@@ -7,6 +7,7 @@ package com.jabbypanda.controls {
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
+ import mx.core.FlexVersion;
import mx.core.mx_internal;
import mx.events.CollectionEvent;
import mx.events.CollectionEventKind;
@@ -49,7 +50,7 @@ package com.jabbypanda.controls {
public function focusListUponKeyboardNavigation(event : KeyboardEvent) : void {
adjustSelectionAndCaretUponNavigation(event);
}
-
+
override protected function dataProvider_collectionChangeHandler(event:Event):void {
super.dataProvider_collectionChangeHandler(event);
View
28 src/com/jabbypanda/controls/InputAssist.as
@@ -15,6 +15,7 @@ package com.jabbypanda.controls {
import mx.core.FlexGlobals;
import mx.core.mx_internal;
import mx.events.CollectionEvent;
+ import mx.events.FlexEvent;
import mx.events.FlexMouseEvent;
import mx.events.ItemClickEvent;
import mx.managers.SystemManager;
@@ -54,8 +55,8 @@ package com.jabbypanda.controls {
public var requireSelection : Boolean = false;
- [SkinPart(required="true",type="spark.components.PopUpAnchor")]
- public var popUp : PopUpAnchor;
+ [SkinPart(required="true",type="com.jabbypanda.controls.PopUpAnchorFixed")]
+ public var popUp : PopUpAnchorFixed;
[SkinPart(required="true",type="odyssey.common.component.HighlightItemList")]
public var list : HighlightItemList;
@@ -92,18 +93,15 @@ package com.jabbypanda.controls {
[Bindable]
public function set dataProvider(value : Object) : void {
- if (_collection) {
- _collection.removeEventListener(CollectionEvent.COLLECTION_CHANGE, onDataProviderCollectionChange);
- }
if (value is Array) {
_collection = new ListCollectionView(new ArrayList(value as Array));
} else if (value is ArrayList) {
ArrayList(value).addEventListener(CollectionEvent.COLLECTION_CHANGE, onDataProviderCollectionChange, false, 0, true);
- _collection = new ListCollectionView(value as ArrayList);
+ _collection = new ListCollectionView(value as ArrayList);
} else if (value is ArrayCollection) {
ArrayCollection(value).addEventListener(CollectionEvent.COLLECTION_CHANGE, onDataProviderCollectionChange, false, 0, true);
- _collection = new ListCollectionView((value as ArrayCollection).list);
+ _collection = new ListCollectionView((value as ArrayCollection).list);
} else {
_collection = new ListCollectionView();
}
@@ -252,11 +250,12 @@ package com.jabbypanda.controls {
list.styleName = new StyleProxy(this, {});
list.addEventListener(ItemClickEvent.ITEM_CLICK, onListItemClick, false, 0, true);
+ list.addEventListener(FlexEvent.UPDATE_COMPLETE, onListUpdateComplete, false, 0, true);
}
}
override protected function commitProperties():void {
- if (_dataProviderChanged) {
+ if (_dataProviderChanged) {
//reset selectedItem to null if it is anymore present in dataProvider
if (!isSelectedItemValid(selectedItem)) {
selectedItem = null;
@@ -275,7 +274,7 @@ package com.jabbypanda.controls {
displayInputTextText(selectedItem);
}
}
-
+
_dataProviderChanged = false;
}
@@ -332,8 +331,6 @@ package com.jabbypanda.controls {
if (_collection) {
_collection.filterFunction = filterFunction;
_collection.refresh();
-
- callLater(popUp.updatePopUpTransform);
}
}
@@ -442,11 +439,11 @@ package com.jabbypanda.controls {
return false;
}
- private function onDataProviderCollectionChange(event : CollectionEvent) : void {
+ private function onDataProviderCollectionChange(event : CollectionEvent) : void {
_dataProviderChanged = true;
invalidateProperties();
}
-
+
private function onInputFieldChange(event : TextOperationEvent = null) : void {
_completionAccepted = false;
enteredText = inputTxt.text;
@@ -489,11 +486,16 @@ package com.jabbypanda.controls {
}
}
+
private function onListItemClick(event : ItemClickEvent) : void {
acceptCompletion();
event.stopPropagation();
}
+ private function onListUpdateComplete(event : FlexEvent) : void {
+ popUp.updatePopUpTransform();
+ }
+
private function onMouseDownOutside(event:FlexMouseEvent) : void {
var mouseDownInsideComponent : Boolean = false;
var clickedObject : DisplayObjectContainer = event.relatedObject as DisplayObjectContainer;
View
92 src/com/jabbypanda/controls/PopUpAnchorFixed.as
@@ -0,0 +1,92 @@
+package com.jabbypanda.controls
+{
+ import flash.display.DisplayObject;
+ import flash.display.Stage;
+ import flash.display.StageDisplayState;
+ import flash.geom.ColorTransform;
+ import flash.geom.Matrix;
+ import flash.geom.Point;
+
+ import mx.core.UIComponent;
+ import mx.core.mx_internal;
+ import mx.utils.MatrixUtil;
+
+ import spark.components.PopUpAnchor;
+
+ use namespace mx_internal;
+
+ public class PopUpAnchorFixed extends PopUpAnchor
+ {
+
+ public function PopUpAnchorFixed()
+ {
+ super();
+ }
+
+ override public function updatePopUpTransform():void
+ {
+ var m:Matrix = MatrixUtil.getConcatenatedMatrix(this);
+
+ // Set the dimensions explicitly because UIComponents always set themselves to their
+ // measured / explicit dimensions if they are parented by the SystemManager.
+ if (popUp is UIComponent)
+ {
+ if (popUpWidthMatchesAnchorWidth) {
+ UIComponent(popUp).width = unscaledWidth;
+ }
+
+ if (popUpHeightMatchesAnchorHeight) {
+ UIComponent(popUp).height = unscaledHeight;
+ }
+
+ }
+ else
+ {
+ var w:Number = popUpWidthMatchesAnchorWidth ? unscaledWidth : popUp.measuredWidth;
+ var h:Number = popUpHeightMatchesAnchorHeight ? unscaledHeight : popUp.measuredHeight;
+ popUp.setActualSize(w, h);
+ }
+
+ var popUpPoint:Point = calculatePopUpPosition();
+
+ // the transformation doesn't take the fullScreenRect in to account
+ // if we are in fulLScreen mode. This code will throw a RTE if run from inside of a sandbox.
+ try
+ {
+ var smStage:Stage = systemManager.stage;
+ if (smStage && smStage.displayState != StageDisplayState.NORMAL && smStage.fullScreenSourceRect)
+ {
+ popUpPoint.x += smStage.fullScreenSourceRect.x;
+ popUpPoint.y += smStage.fullScreenSourceRect.y;
+ }
+ }
+ catch (e:Error)
+ {
+ // Ignore the RTE
+ }
+
+ if (!m)
+ return;
+
+ // Position the popUp.
+ m.tx = Math.round(popUpPoint.x);
+ m.ty = Math.round(popUpPoint.y);
+ if (popUp is UIComponent)
+ UIComponent(popUp).setLayoutMatrix(m,false);
+ else if (popUp is DisplayObject)
+ DisplayObject(popUp).transform.matrix = m;
+
+ //super.updatePopUpTransform();
+
+ // apply the color transformation, but restore alpha value of popup
+ var oldAlpha:Number = DisplayObject(popUp).alpha;
+ var tmpColorTransform:ColorTransform = $transform.concatenatedColorTransform;
+ if (tmpColorTransform != null)
+ {
+ tmpColorTransform.alphaMultiplier = oldAlpha;
+ tmpColorTransform.alphaOffset = 0;
+ }
+ DisplayObject(popUp).transform.colorTransform = tmpColorTransform;
+ }
+ }
+}
View
27 src/com/jabbypanda/skins/InputAssistSkin.mxml
@@ -27,21 +27,20 @@
The PopUpAnchor control that opens the drop-down list.
-->
- <s:PopUpAnchor id="popUp" displayPopUp="false"
+ <c:PopUpAnchorFixed id="popUp" displayPopUp="false"
top="0" bottom="0" left="0" right="0"
- popUpWidthMatchesAnchorWidth="true"
- popUpPosition="below">
- <s:Group id="dropDown" width="100%">
- <c:HighlightItemList id="list" width="100%"
- itemRenderer="com.jabbypanda.renderers.HighlightListItemRenderer">
- <c:layout>
- <s:VerticalLayout horizontalAlign="justify"
- gap="0"
- requestedRowCount="{Math.min(hostComponent.maxRows, hostComponent.dataProvider.length)}"/>
- </c:layout>
- </c:HighlightItemList>
- </s:Group>
- </s:PopUpAnchor>
+ popUpWidthMatchesAnchorWidth="true"
+ popUpPosition="below">
+ <c:HighlightItemList id="list"
+ width="100%"
+ itemRenderer="com.jabbypanda.renderers.HighlightListItemRenderer">
+ <c:layout>
+ <s:VerticalLayout
+ useVirtualLayout="false"
+ requestedMinRowCount="1"/>
+ </c:layout>
+ </c:HighlightItemList>
+ </c:PopUpAnchorFixed>
<s:TextInput id="inputTxt" left="0" right="0" top="0" bottom="0"/>
<s:BitmapImage source="{Icons.Progress}"
visible="{hostComponent.processing}"
Please sign in to comment.
Something went wrong with that request. Please try again.