[flexcoders] Re: PopupManager causes RangeError: Error #2006: adding a popup window
Alex -- I just saw that you had responded to my older post -- I haven't been monitoring it since I found my own work-around. Yes, you have correctly identified the situation that the itemEditEnd is called twice (for two different cells). You asked the question what's the user task goal and what are you really trying to popup?. In this case the user has entered some text into a datagrid cell that is ambiguous. The pop-up provides a list of the possible matches for the user-entered text along with some additional information about each choice and a couple of buttons to choose one or cancel out. (This is a Flight Planning type of application for pilots. If they enter SAN they may have wanted the San Diego airport. *Or* they may have wanted one of the 17 other locations that start with SAN... such as SANGO, SANFI, SANFD, etc.) This particular use-case is used in a number of other commercial Flight Planners, so the use of a pop-up is quite expected in this user community. My current pop-up code seems to be working OK at this point. I have actually implemented your suggestions about setting focus to the button in the popup on creationComplete. Hope this explanation of how this is being used can be helpful in the future as you look at issues such as focus in the AdvancedDataGrid and consider all of the possible use-cases that may be out there. I'm sure it's quite a job! --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: The DataGrid does not like having popups come up during edit sessions. It is trying to manage focus between editors as the popup tries to take away the focus. There's also a 'problem' in your code that itemEditEnd can be called twice, once as you leave the cell, and again as the dg tries to move to a new cell and you lose focus to the popup and have to kill that editor too. I'd add logic as to whether you have a popup up or not, I would also regenerate the popup every time instead of re-using it and set focus in the creationComplete handler to the button in the popup. There may still be cases that won't work. I'd try to avoid this kind of UI if possible, popups are rather jarring. What are you really trying to popup? What's the user task goal? From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of wpbarto Sent: Tuesday, December 11, 2007 2:14 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] PopupManager causes RangeError: Error #2006: adding a popup window I saw something else similar in flexcoders, but the information didn't seem to apply to this case. I can create a popup window from a button's click handler, but THE SAME CODE used when editing a DataGrid cell FAILS! Is it a bug or a mis-use of PopupManager?? Thanks for any help! Top part of Error stack: RangeError: Error #2006: The supplied index is out of bounds. at flash.display::DisplayObjectContainer/addChildAt() at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal: http://www.adobe.com/2006/flex/mx/internal: :rawChildren_addChildAt() at mx.managers::SystemManager/addChild() at mx.managers::PopUpManagerImpl/addPopUp() at mx.managers::PopUpManager$/addPopUp() at TestPopup/::onCellEdit() at TestPopup/__pointGrid_itemEditEnd() at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEv entFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.controls::DataGrid/::endEdit() at mx.controls::DataGrid/::deactivateHandler() at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEv entFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.controls::DataGrid/::endEdit() This is the smallest example I can create: [File1: TestPopup.mxml] == ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute applicationComplete=onAppComplete() mx:Script ![CDATA[ import mx.managers.PopUpManager; import mx.collections.ArrayCollection; import mx.events.DataGridEvent; import mx.events.DataGridEventReason; private var popWin:MyPopupWindow = null; private var curData:ArrayCollection; // items for datagrid private var items:ArrayCollection; // items for pop up private function onAppComplete():void { curData = new ArrayCollection(); curData.addItem( { ident:ORD, cityname:Chicago, IL } ); curData.addItem( { ident:ATL, cityname:Atlanta, GA } ); curData.addItem( { ident:DEN, cityname:Denver, CO } ); curData.addItem( { ident:, cityname: } ); // one blank pointGrid.rowCount = 5; pointGrid.dataProvider = curData; items = new ArrayCollection(); items.addItem( {ident:JFK, cityname:New York, NY} ); items.addItem( {ident:LAX, cityname:Los Angeles, CA} ); items.addItem( {ident:SEA,
Re: [flexcoders] Re: PopupManager causes RangeError: Error #2006: adding a popup window
The problem in your code friend is because you´re trying to add itens to an datagrid without existing first. you can only add that if you have already created the container for it. so addChild or initiate the popup before you do that. and will works. regards Igor Costa www.igorcosta.org www.igorcosta.com On Dec 12, 2007 1:49 AM, wpbarto [EMAIL PROTECTED] wrote: Additional Info: This problem is apparantly caused by MULTIPLE itemEditEnd events dispatched from the DataGrid, exacerbated by the fact that the PopupManager code is not reentrant or doesn't handle concurrency. Looks like Flash player can interrupt part of a running script (PopupManager's addPopup thread) and begin additional events. So: 1. Why is dataGrid sending 4-5 (!) itemEditEnd events for one edit action? 2. Shouldn't PopupManager be reliable and opaque without developers having to code around it's quirks? (Don't get me wrong--I love Flex; just don't like banging my head over framework issues. I have enough banging for my own issues!) --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, wpbarto [EMAIL PROTECTED] wrote: I saw something else similar in flexcoders, but the information didn't seem to apply to this case. I can create a popup window from a button's click handler, but THE SAME CODE used when editing a DataGrid cell FAILS! Is it a bug or a mis-use of PopupManager?? Thanks for any help! Top part of Error stack: RangeError: Error #2006: The supplied index is out of bounds. at flash.display::DisplayObjectContainer/addChildAt() at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal: :rawChildren_addChildAt() at mx.managers::SystemManager/addChild() at mx.managers::PopUpManagerImpl/addPopUp() at mx.managers::PopUpManager$/addPopUp() at TestPopup/::onCellEdit() at TestPopup/__pointGrid_itemEditEnd() at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEv entFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.controls::DataGrid/::endEdit() at mx.controls::DataGrid/::deactivateHandler() at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEv entFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.controls::DataGrid/::endEdit() This is the smallest example I can create: [File1: TestPopup.mxml] == ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute applicationComplete=onAppComplete() mx:Script ![CDATA[ import mx.managers.PopUpManager; import mx.collections.ArrayCollection; import mx.events.DataGridEvent; import mx.events.DataGridEventReason; private var popWin:MyPopupWindow = null; private var curData:ArrayCollection; // items for datagrid private var items:ArrayCollection; // items for pop up private function onAppComplete():void { curData = new ArrayCollection(); curData.addItem( { ident:ORD, cityname:Chicago, IL } ); curData.addItem( { ident:ATL, cityname:Atlanta, GA } ); curData.addItem( { ident:DEN, cityname:Denver, CO } ); curData.addItem( { ident:, cityname: } ); // one blank pointGrid.rowCount = 5; pointGrid.dataProvider = curData; items = new ArrayCollection(); items.addItem( {ident:JFK, cityname:New York, NY} ); items.addItem( {ident:LAX, cityname:Los Angeles, CA} ); items.addItem( {ident:SEA, cityname:Seattle, WA} ); } private function onClick():void { if(popWin == null) { popWin = new MyPopupWindow(); popWin.itemChoices = items; } PopUpManager.addPopUp(popWin, this, true); PopUpManager.centerPopUp(popWin); } private function onCellEdit(event:DataGridEvent):void { if(event.reason == DataGridEventReason.CANCELLED) return; if(popWin == null) { popWin = new MyPopupWindow(); popWin.itemChoices = items; } PopUpManager.addPopUp(popWin, this, true); PopUpManager.centerPopUp(popWin); } ]] /mx:Script mx:VBox mx:Label text=Clicking the button creates popup OK: / mx:Button id=theButton label=Click Me click=onClick()/ mx:Label text=However, editing a cell FIRST fails: / mx:DataGrid id=pointGrid itemEditEnd=onCellEdit(event) editable=true mx:columns mx:DataGridColumn id=identCol width=50 dataField=ident headerText=Ident/ mx:DataGridColumn id=citynameCol width=90 dataField=cityname headerText=City/Name paddingLeft=1 paddingRight=1/ /mx:columns /mx:DataGrid /mx:VBox /mx:Application [File2: MyPopupWindow.mxml] == ?xml version=1.0 encoding=utf-8? mx:Panel xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute width=400 height=300 title=The Popup Window mx:DataGrid id=selItemList dataProvider={itemChoices} width=100% height=100% mx:columns
[flexcoders] Re: PopupManager causes RangeError: Error #2006: adding a popup window
Additional Info: This problem is apparantly caused by MULTIPLE itemEditEnd events dispatched from the DataGrid, exacerbated by the fact that the PopupManager code is not reentrant or doesn't handle concurrency. Looks like Flash player can interrupt part of a running script (PopupManager's addPopup thread) and begin additional events. So: 1. Why is dataGrid sending 4-5 (!) itemEditEnd events for one edit action? 2. Shouldn't PopupManager be reliable and opaque without developers having to code around it's quirks? (Don't get me wrong--I love Flex; just don't like banging my head over framework issues. I have enough banging for my own issues!) --- In flexcoders@yahoogroups.com, wpbarto [EMAIL PROTECTED] wrote: I saw something else similar in flexcoders, but the information didn't seem to apply to this case. I can create a popup window from a button's click handler, but THE SAME CODE used when editing a DataGrid cell FAILS! Is it a bug or a mis-use of PopupManager?? Thanks for any help! Top part of Error stack: RangeError: Error #2006: The supplied index is out of bounds. at flash.display::DisplayObjectContainer/addChildAt() at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal: :rawChildren_addChildAt() at mx.managers::SystemManager/addChild() at mx.managers::PopUpManagerImpl/addPopUp() at mx.managers::PopUpManager$/addPopUp() at TestPopup/::onCellEdit() at TestPopup/__pointGrid_itemEditEnd() at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEv entFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.controls::DataGrid/::endEdit() at mx.controls::DataGrid/::deactivateHandler() at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEv entFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.controls::DataGrid/::endEdit() This is the smallest example I can create: [File1: TestPopup.mxml] == ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute applicationComplete=onAppComplete() mx:Script ![CDATA[ import mx.managers.PopUpManager; import mx.collections.ArrayCollection; import mx.events.DataGridEvent; import mx.events.DataGridEventReason; private var popWin:MyPopupWindow = null; private var curData:ArrayCollection;// items for datagrid private var items:ArrayCollection; // items for pop up private function onAppComplete():void { curData = new ArrayCollection(); curData.addItem( { ident:ORD, cityname:Chicago, IL } ); curData.addItem( { ident:ATL, cityname:Atlanta, GA } ); curData.addItem( { ident:DEN, cityname:Denver, CO } ); curData.addItem( { ident:, cityname: } ); // one blank pointGrid.rowCount = 5; pointGrid.dataProvider = curData; items = new ArrayCollection(); items.addItem( {ident:JFK, cityname:New York, NY} ); items.addItem( {ident:LAX, cityname:Los Angeles, CA} ); items.addItem( {ident:SEA, cityname:Seattle, WA} ); } private function onClick():void { if(popWin == null) { popWin = new MyPopupWindow(); popWin.itemChoices = items; } PopUpManager.addPopUp(popWin, this, true); PopUpManager.centerPopUp(popWin); } private function onCellEdit(event:DataGridEvent):void { if(event.reason == DataGridEventReason.CANCELLED) return; if(popWin == null) { popWin = new MyPopupWindow(); popWin.itemChoices = items; } PopUpManager.addPopUp(popWin, this, true); PopUpManager.centerPopUp(popWin); } ]] /mx:Script mx:VBox mx:Label text=Clicking the button creates popup OK: / mx:Button id=theButton label=Click Me click=onClick()/ mx:Label text=However, editing a cell FIRST fails: / mx:DataGrid id=pointGrid itemEditEnd=onCellEdit(event) editable=true mx:columns mx:DataGridColumn id=identCol width=50 dataField=ident headerText=Ident/ mx:DataGridColumn id=citynameCol width=90 dataField=cityname headerText=City/Name paddingLeft=1 paddingRight=1/ /mx:columns /mx:DataGrid /mx:VBox /mx:Application [File2: MyPopupWindow.mxml] == ?xml version=1.0 encoding=utf-8? mx:Panel xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute width=400 height=300 title=The Popup Window mx:DataGrid id=selItemList dataProvider={itemChoices} width=100% height=100% mx:columns mx:DataGridColumn id=identCol dataField=ident headerText=Ident/