FLEX-34216 accept patch from Mihai Chira
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/4c350ade Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/4c350ade Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/4c350ade Branch: refs/heads/master Commit: 4c350ade7b903fa9ffbafd35b0c0ffff918fd161 Parents: 6517a4b Author: Alex Harui <aha...@apache.org> Authored: Thu Apr 17 10:30:43 2014 -0700 Committer: Alex Harui <aha...@apache.org> Committed: Thu Apr 17 10:30:43 2014 -0700 ---------------------------------------------------------------------- .../components/gridClasses/DataGridEditor.as | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4c350ade/frameworks/projects/spark/src/spark/components/gridClasses/DataGridEditor.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/spark/src/spark/components/gridClasses/DataGridEditor.as b/frameworks/projects/spark/src/spark/components/gridClasses/DataGridEditor.as index 2971962..9aaa3c6 100644 --- a/frameworks/projects/spark/src/spark/components/gridClasses/DataGridEditor.as +++ b/frameworks/projects/spark/src/spark/components/gridClasses/DataGridEditor.as @@ -532,6 +532,7 @@ public class DataGridEditor o.removeEventListener(KeyboardEvent.KEY_DOWN, editor_keyDownHandler); o.removeEventListener(FocusEvent.FOCUS_OUT, editor_focusOutHandler); + o.removeEventListener(Event.REMOVED_FROM_STAGE, editor_removedFromStageHandler); o.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE, editor_keyFocusChangeHandler); addRemoveFlexEventEnterListener(DisplayObject(o), false); @@ -673,7 +674,7 @@ public class DataGridEditor var editor:IEventDispatcher = itemEditorInstance ? itemEditorInstance : editedItemRenderer; editor.addEventListener(FocusEvent.FOCUS_OUT, editor_focusOutHandler); - + editor.addEventListener(Event.REMOVED_FROM_STAGE, editor_removedFromStageHandler); // listen for keyStrokes on the itemEditorInstance (which lets the grid supervise for ESC/ENTER) editor.addEventListener(KeyboardEvent.KEY_DOWN, editor_keyDownHandler); editor.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, editor_keyFocusChangeHandler, false, 1000); @@ -1574,6 +1575,23 @@ public class DataGridEditor * @private * Closes the itemEditorInstance if the focus is outside of the data grid. */ + private function editor_removedFromStageHandler(event:Event):void + { + if (itemEditorInstance || editedItemRenderer) + { + // If we can't save the data, say, because the data was invalid, + // then cancel the save. + if (!dataGrid.endItemEditorSession()) + { + dataGrid.endItemEditorSession(true); + } + } + } + + /** + * @private + * Closes the itemEditorInstance if the focus is outside of the data grid. + */ private function editor_focusOutHandler(event:FocusEvent):void { //trace("editor_focusOutHandler " + event.relatedObject);