FIX FLEX-33166 Mobile TextInput with native StageTextInput cannot be included in scrollable forms - fix issue when tapping in the padding area of a text input - fix issue when tapping several times in and out of text inputs (rep. Collins Childs)
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/9e4bf21f Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/9e4bf21f Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/9e4bf21f Branch: refs/heads/develop Commit: 9e4bf21f9dc8815d67c192f2cea65e2636092c53 Parents: dba8dd3 Author: mamsellem <[email protected]> Authored: Fri Nov 22 11:26:06 2013 +0100 Committer: mamsellem <[email protected]> Committed: Fri Nov 22 11:26:06 2013 +0100 ---------------------------------------------------------------------- .../supportClasses/ScrollableStageText.as | 163 +++++++++---------- .../skins/mobile/ScrollingStageTextAreaSkin.as | 22 +++ .../skins/mobile/ScrollingStageTextInputSkin.as | 22 +++ 3 files changed, 118 insertions(+), 89 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9e4bf21f/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ScrollableStageText.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ScrollableStageText.as b/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ScrollableStageText.as index f14cc38..0c7e2cf 100644 --- a/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ScrollableStageText.as +++ b/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ScrollableStageText.as @@ -429,7 +429,6 @@ public class ScrollableStageText extends UIComponent implements IStyleableEdita private var isEditing:Boolean = false; private var invalidateProxyFlag:Boolean = false; - //-------------------------------------------------------------------------- // // Properties @@ -456,6 +455,9 @@ public class ScrollableStageText extends UIComponent implements IStyleableEdita */ protected var invalidateStyleFlag:Boolean = true; + + private var _softKeyboardType: String = SoftKeyboardType.DEFAULT; + //-------------------------------------------------------------------------- // // Properties @@ -1137,10 +1139,6 @@ public class ScrollableStageText extends UIComponent implements IStyleableEdita // softKeyboardType //---------------------------------- - /** - * Storage for the softKeyboardType property. - */ - private var _softKeyboardType:String = SoftKeyboardType.DEFAULT; /** * @inheritDoc @@ -1503,57 +1501,6 @@ public class ScrollableStageText extends UIComponent implements IStyleableEdita } - //-------------------------------------------------------------------------- - // - // EDITING AND FOCUS MANAGEMENT - // - //-------------------------------------------------------------------------- - - /** - * @return true if editing was actually stated,, false is already started - * */ - protected function startTextEdit():Boolean - { - if (!isEditing) - { - isEditing = true; - proxy.visible = false; - updateViewPort(); - stageText.visible = true; - return true; - } - else { - return false; - } - } - - /** - * @return true if editing was actually ended, false is already ended - * */ - protected function endTextEdit():Boolean - { - if (isEditing) - { - isEditing = false; - invalidateProxy(); - proxy.visible = true; - stageText.visible = false; - - if (focusManager is FocusManager) - { - var fm:FocusManager = focusManager as FocusManager; - var lastFocus:Object = fm.lastFocus as Object; - - if (lastFocus && lastFocus.hasOwnProperty("textDisplay") && lastFocus.textDisplay == this) - fm.lastFocus = null; - } - return true; - } - else { - return false; - } - } - //-------------------------------------------------------------------------- // Proxy Management //-------------------------------------------------------------------------- @@ -1778,13 +1725,6 @@ public class ScrollableStageText extends UIComponent implements IStyleableEdita savedSelectionActiveIndex = 0; } -// if (deferredViewPortUpdate) -// updateViewPort(); - - // always create proxy image - - // register listeners - addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); addEventListener(TouchInteractionEvent.TOUCH_INTERACTION_STARTING, touchStartingHandler); if (stageText != null) { @@ -1810,9 +1750,7 @@ public class ScrollableStageText extends UIComponent implements IStyleableEdita savedSelectionAnchorIndex = stageText.selectionAnchorIndex; savedSelectionActiveIndex = stageText.selectionActiveIndex; - stageText.stage = null; - removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); addEventListener(TouchInteractionEvent.TOUCH_INTERACTION_STARTING, touchStartingHandler); stageText.removeEventListener(Event.CHANGE, stageText_changeHandler); stageText.removeEventListener(Event.COMPLETE, stageText_completeHandler); @@ -1837,18 +1775,6 @@ public class ScrollableStageText extends UIComponent implements IStyleableEdita } } - private function mouseDownHandler(event:MouseEvent):void - { - setFocus(); - } - - private function touchStartingHandler(event:Event):void - { - // don't allow touch scrolling while editing (of the StageText will stay in place) - if (isEditing) - event.preventDefault(); - } - protected function stageText_changeHandler(event:Event):void { var foundChange:Boolean = false; @@ -1872,29 +1798,41 @@ public class ScrollableStageText extends UIComponent implements IStyleableEdita invalidateProperties(); } + + + private function touchStartingHandler(event: Event): void + { + // don't allow touch scrolling while editing (of the StageText will stay in place) + if (isEditing) + event.preventDefault(); + } + private function stageText_focusInHandler(event:FocusEvent):void { - if (startTextEdit()){ + if (!isEditing){ + startTextEdit(); + } // Focus events are documented as bubbling. However, all events coming // from StageText are set to not bubble. So we need to create an // appropriate bubbling event here. - dispatchEvent(new FocusEvent(event.type, true, event.cancelable, - event.relatedObject, event.shiftKey, event.keyCode, event.direction)); - } + dispatchEvent(new FocusEvent(event.type, true, event.cancelable, + event.relatedObject, event.shiftKey, event.keyCode, event.direction)); } private function stageText_focusOutHandler(event:FocusEvent):void { - if (endTextEdit()) { - // Focus events are documented as bubbling. However, all events coming - // from StageText are set to not bubble. So we need to create an - // appropriate bubbling event here. - dispatchEvent(new FocusEvent(event.type, true, event.cancelable, - event.relatedObject, event.shiftKey, event.keyCode, event.direction)); + if (isEditing) + { + endTextEdit(); } - + // Focus events are documented as bubbling. However, all events coming + // from StageText are set to not bubble. So we need to create an + // appropriate bubbling event here. + dispatchEvent(new FocusEvent(event.type, true, event.cancelable, + event.relatedObject, event.shiftKey, event.keyCode, event.direction)); } + private function stageText_keyDownHandler(event:KeyboardEvent):void { // Taps on the Enter key on soft keyboards may send us the Next keycode @@ -1945,12 +1883,59 @@ public class ScrollableStageText extends UIComponent implements IStyleableEdita private function stageText_softKeyboardDeactivateHandler(event:SoftKeyboardEvent):void { - if (endTextEdit()) { dispatchEvent(new SoftKeyboardEvent(event.type, true, event.cancelable, this, event.triggerType)); + } + + //-------------------------------------------------------------------------- + // + // EDITING + // + //-------------------------------------------------------------------------- + + /** + * @return true if editing was actually stated,, false is already started + * */ + protected function startTextEdit(): Boolean + { + if (!isEditing) + { + // trace("start text edit:", debugId); + isEditing = true; + proxy.visible = false; + updateViewPort(); + stageText.visible = true; + return true; + } + else + { + return false; + } + } + + /** + * @return true if editing was actually ended, false is already ended + * */ + protected function endTextEdit(): Boolean + { + // if owning TextInput mouseDown is the cause of focus out, abort + + if (isEditing) + { + // trace("end text edit:", debugId); + isEditing = false; + invalidateProxy(); + proxy.visible = true; + stageText.visible = false; + return true; + } + else + { + return false; } } + /* debug */ protected function get debugId():String { var parentSkin: UIComponent = this.parent.parent as UIComponent; return parentSkin ? parentSkin.id : "-" ; http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9e4bf21f/frameworks/projects/mobiletheme/src/spark/skins/mobile/ScrollingStageTextAreaSkin.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/mobiletheme/src/spark/skins/mobile/ScrollingStageTextAreaSkin.as b/frameworks/projects/mobiletheme/src/spark/skins/mobile/ScrollingStageTextAreaSkin.as index bdf9edf..1990a4a 100644 --- a/frameworks/projects/mobiletheme/src/spark/skins/mobile/ScrollingStageTextAreaSkin.as +++ b/frameworks/projects/mobiletheme/src/spark/skins/mobile/ScrollingStageTextAreaSkin.as @@ -19,6 +19,9 @@ package spark.skins.mobile { +import flash.display.DisplayObjectContainer; +import flash.events.MouseEvent; + import spark.components.supportClasses.IStyleableEditableText; import spark.components.supportClasses.ScrollableStageText; @@ -39,11 +42,30 @@ public class ScrollingStageTextAreaSkin extends StageTextAreaSkin public function ScrollingStageTextAreaSkin() { super(); + addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); } override protected function createTextDisplay():IStyleableEditableText { return new ScrollableStageText(multiline); + + } + + /** @private + * We have to force focus to the text display when user user in the padding area of the TextInput. + we do this hack in the skin instead of the hostComponent TextInput to not impact the behavior of other skins + */ + override public function set owner(value: DisplayObjectContainer): void + { + super.owner = value; + if (owner){ + owner.mouseEnabled = false; + } + } + + private function mouseDownHandler(event: MouseEvent): void + { + textDisplay.setFocus(); } } } http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9e4bf21f/frameworks/projects/mobiletheme/src/spark/skins/mobile/ScrollingStageTextInputSkin.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/mobiletheme/src/spark/skins/mobile/ScrollingStageTextInputSkin.as b/frameworks/projects/mobiletheme/src/spark/skins/mobile/ScrollingStageTextInputSkin.as index d856d53..61e37df 100644 --- a/frameworks/projects/mobiletheme/src/spark/skins/mobile/ScrollingStageTextInputSkin.as +++ b/frameworks/projects/mobiletheme/src/spark/skins/mobile/ScrollingStageTextInputSkin.as @@ -19,6 +19,9 @@ package spark.skins.mobile { +import flash.display.DisplayObjectContainer; +import flash.events.MouseEvent; + import spark.components.supportClasses.IStyleableEditableText; import spark.components.supportClasses.ScrollableStageText; @@ -39,11 +42,30 @@ public class ScrollingStageTextInputSkin extends StageTextInputSkin public function ScrollingStageTextInputSkin() { super(); + addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); } override protected function createTextDisplay():IStyleableEditableText { return new ScrollableStageText(multiline); + + } + + /** @private + * We have to force focus to the text display when user user in the padding area of the TextInput. + we do this hack in the skin instead of the hostComponent TextInput to not impact the behavior of other skins + */ + override public function set owner(value: DisplayObjectContainer): void + { + super.owner = value; + if (owner){ + owner.mouseEnabled = false; + } + } + + private function mouseDownHandler(event: MouseEvent): void + { + textDisplay.setFocus(); } } }
