I added a "dg.disposeEditor();" line before setting the focused cell
to the old cell when not changing the focus. This seems to make it
work .... Alternatively, you could use "dg.focusedCell = undefined;"
Jim
function doCellPressFocusIn(event)
{
if(changeFocus)
{
var obj1 = oldCell =
{itemIndex:event.itemIndex, columnIndex:event.columnIndex};
dg.focusedCell = obj1;
}
else
{
dg.focusedCell = undefined;
dg.focusedCell = oldCell;
}
On 5/4/05, bhaq1972 <[EMAIL PROTECTED]> wrote:
> Hi
> I'm doing a simple test where i store the position of a focusedCell
> during a cellPress/cellFocusIn event.
>
> If i then set a boolean variable to false, i want the celleditor to
> appaer in the original position. This works except the green box
> appears in the new position.
> I want this green box to appear around the cellEditor all the time.
>
> heres an example of what i mean.
>
> TIA
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
> xmlns="*" backgroundColor="#C0DCC2">
>
> <mx:Script>
> <![CDATA[
>
> var dp = [ { one:"one", two:"two",
> three:"three" },
> { one:"four", two:"five",
> three:"six" },
> { one:"seven", two:"eight",
> three:"nine" },
> { one:"ten", two:"eleven",
> three:"twelve" },
> { one:"thirteen",
> two:"fourteen", three:"fifteen" }];
>
> var changeFocus:Boolean = true;
> var oldCell;
>
> function doCellPressFocusIn(event)
> {
> if(changeFocus)
> {
> var obj1 = oldCell =
> {itemIndex:event.itemIndex, columnIndex:event.columnIndex};
> dg.focusedCell = obj1;
> }
> else
> {
> dg.focusedCell = oldCell;
> }
> }
>
> ]]>
> </mx:Script>
>
> <mx:TextArea width="200" height="100" text="Select a cell
> from datagrid, then click the button, it should remain focused on
> the previously clicked cell .... not always though"/>
> <mx:DataGrid selectable="false" editable="true" id="dg"
> dataProvider="{ dp }" cellFocusIn="doCellPressFocusIn(event)"
> cellPress="doCellPressFocusIn(event)">
> <mx:columns>
> <mx:Array>
> <mx:DataGridColumn columnName="one"/>
> <mx:DataGridColumn
> columnName="two" />
> <mx:DataGridColumn
> columnName="three"/>
> </mx:Array>
> </mx:columns>
> </mx:DataGrid>
> <mx:Button label="Button" click="changeFocus=!
> changeFocus;" />
>
> </mx:Application>
>
>
> Yahoo! Groups Links
>
>
>
>
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/