You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2020/01/21 17:29:27 UTC
[royale-asjs] 02/03: get RichEditableText to display text
This is an automated email from the ASF dual-hosted git repository.
aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 4024603a69152f4b1f0f01cdaebd5da9e3bc91c5
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Jan 20 21:45:19 2020 -0800
get RichEditableText to display text
---
.../src/main/royale/mx/events/FlexEvent.as | 2 +-
.../royale/spark/components/RichEditableText.as | 365 +++++-----
.../src/main/royale/spark/components/Scroller.as | 2 +-
.../src/main/royale/spark/components/TextArea.as | 15 +-
.../RichEditableTextContainerManager.as | 795 +++++++++++++++++++++
.../components/supportClasses/SkinnableTextBase.as | 93 +--
6 files changed, 1065 insertions(+), 207 deletions(-)
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/events/FlexEvent.as b/frameworks/projects/MXRoyale/src/main/royale/mx/events/FlexEvent.as
index 83aaa58..a511c05 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/events/FlexEvent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/events/FlexEvent.as
@@ -1130,7 +1130,7 @@ public class FlexEvent extends Event
* @playerversion AIR 1.1
* @productversion Royale 0.9.3
*/
- //public static const SELECTION_CHANGE:String = "selectionChange";
+ public static const SELECTION_CHANGE:String = "selectionChange";
/**
* The <code>FlexEvent.SHOW</code> constant defines the value of the
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/RichEditableText.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/RichEditableText.as
index edf9b69..702c9d2 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/RichEditableText.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/RichEditableText.as
@@ -38,11 +38,7 @@ package spark.components
import flash.ui.Keyboard;
import flashx.textLayout.compose.ISWFContext;
- import flashx.textLayout.container.TextContainerManager;
import flashx.textLayout.conversion.ConversionType;
- import flashx.textLayout.conversion.ITextExporter;
- import flashx.textLayout.conversion.ITextImporter;
- import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.edit.EditingMode;
import flashx.textLayout.edit.IEditManager;
@@ -79,23 +75,39 @@ package spark.components
import mx.core.IFlexModuleFactory;
import mx.core.IIMESupport;
import mx.core.ISystemCursorClient;
- import mx.core.mx_internal;
import mx.managers.IFocusManager;
- import mx.utils.StringUtil;
- import spark.components.supportClasses.RichEditableTextContainerManager;
- import spark.core.CSSTextLayoutFormat;
- import spark.core.IEditableText;
import spark.core.IViewport;
+ import spark.core.CSSTextLayoutFormat;
import spark.core.NavigationUnit;
import spark.events.TextOperationEvent;
import spark.utils.TextUtil;
- use namespace mx_internal;
use namespace tlf_internal; */
- import org.apache.royale.textLayout.elements.TextFlow;
+
+ import mx.core.IVisualElement;
+ import mx.core.UIComponent;
+ import mx.core.mx_internal;
import mx.events.FlexEvent;
- import mx.core.UIComponent;
+ import mx.utils.StringUtil;
+
+ import spark.components.supportClasses.RichEditableTextContainerManager;
+ import spark.core.IEditableText;
+
+ import org.apache.royale.textLayout.container.TextContainerManager;
+ import org.apache.royale.textLayout.conversion.ITextExporter;
+ import org.apache.royale.textLayout.conversion.ITextImporter;
+ import org.apache.royale.textLayout.conversion.TextConverter;
+ import org.apache.royale.textLayout.edit.EditingMode;
+ import org.apache.royale.textLayout.edit.ISelectionManager;
+ import org.apache.royale.textLayout.edit.SelectionState;
+ import org.apache.royale.textLayout.elements.TextFlow;
+ import org.apache.royale.textLayout.events.SelectionEvent;
+ import org.apache.royale.textLayout.factory.TLFFactory;
+ import org.apache.royale.textLayout.factory.StandardTLFFactory;
+ import org.apache.royale.textLayout.factory.TextFlowTextLineFactory;
+ import org.apache.royale.textLayout.factory.TextLineFactoryBase;
+ use namespace mx_internal;
import mx.managers.IFocusManagerComponent;
@@ -440,9 +452,9 @@ package spark.components
* @see flashx.textLayout.container.TextContainerManager
*/
public class RichEditableText extends UIComponent
- implements IFocusManagerComponent
+ implements IFocusManagerComponent, IVisualElement, IEditableText
{
- //, IIMESupport, ISystemCursorClient,IViewport, IEditableText
+ //, IIMESupport, ISystemCursorClient, IViewport
// include "../core/Version.as";
//--------------------------------------------------------------------------
@@ -474,11 +486,15 @@ package spark.components
* related to whether this class or the TLF classes
* that it uses are initialized first.
*/
- /* private static function initClass():void
+ private static function initClass():void
{
if (classInitialized)
return;
+ if (!TLFFactory.defaultTLFFactory)
+ TLFFactory.defaultTLFFactory = new StandardTLFFactory();
+
+ /*
// Set the TLF hook used for localizing runtime error messages.
// TLF itself has English-only messages,
// but higher layers like Flex can provide localized versions.
@@ -493,6 +509,7 @@ package spark.components
// measure as the rest of the remaining width up to 10000.
GlobalSettings.enableDefaultTabStops =
!Configuration.playerEnablesArgoFeatures;
+ */
staticPlainTextImporter =
TextConverter.getImporter(TextConverter.PLAIN_TEXT_FORMAT);
@@ -505,7 +522,7 @@ package spark.components
TextConverter.getExporter(TextConverter.PLAIN_TEXT_FORMAT);
classInitialized = true;
- } */
+ }
//--------------------------------------------------------------------------
//
@@ -516,7 +533,7 @@ package spark.components
/**
* @private
*/
- //private static var classInitialized:Boolean = false;
+ private static var classInitialized:Boolean = false;
/**
* @private
@@ -540,14 +557,14 @@ package spark.components
* This TLF object is used to import a 'text' String
* containing linebreaks to create a multiparagraph TextFlow.
*/
- //private static var staticPlainTextImporter:ITextImporter;
+ private static var staticPlainTextImporter:ITextImporter;
/**
* @private
* This TLF object is used to export a TextFlow as plain 'text',
* by walking the leaf FlowElements in the TextFlow.
*/
- //private static var staticPlainTextExporter:ITextExporter;
+ private static var staticPlainTextExporter:ITextExporter;
/**
* @private
@@ -616,7 +633,7 @@ package spark.components
{
super();
- /* initClass();
+ initClass();
// Use the setter.
text = "";
@@ -627,6 +644,7 @@ package spark.components
// of the component.
_textContainerManager = createTextContainerManager();
+ /*
// Turn on TextField-like behavior which preserves the selection when text is set.
// If the new text is shorter than the exisiting text, the selection may change.
if (FlexVersion.compatibilityVersion > FlexVersion.VERSION_4_8)
@@ -713,7 +731,7 @@ package spark.components
* @private
* Source of text: one of "text", "textFlow" or "content".
*/
- // private var source:String = "text";
+ private var source:String = "text";
/**
* @private
@@ -721,14 +739,14 @@ package spark.components
* determine whether to return immediately from damage event if there
* have been no changes.
*/
- // private var lastGeneration:uint = 0; // 0 means not set
+ private var lastGeneration:uint = 0; // 0 means not set
/**
* @private
* The generation of the text flow that last reported its content
* bounds.
*/
- // private var lastContentBoundsGeneration:int = 0; // 0 means not set
+ private var lastContentBoundsGeneration:int = 0; // 0 means not set
/**
* @private
@@ -745,17 +763,17 @@ package spark.components
/**
* @private
*/
- // private var inUpdateDLMethod:Boolean = false;
+ private var inUpdateDLMethod:Boolean = false;
/**
* @private
*/
- // private var remeasuringText:Boolean = false;
+ private var remeasuringText:Boolean = false;
/**
* @private
*/
- // mx_internal var passwordChar:String = "*";
+ mx_internal var passwordChar:String = "*";
/**
* @private
@@ -806,14 +824,14 @@ package spark.components
* Cache the width constraint as set by the layout in setLayoutBoundsSize()
* so that text reflow can be calculated during a subsequent measure pass.
*/
- // private var widthConstraint:Number = NaN;
+ private var widthConstraint:Number = NaN;
/**
* @private
* Cache the height constraint as set by the layout in setLayoutBoundsSize()
* so that text reflow can be calculated during a subsequent measure pass.
*/
- // private var heightConstraint:Number = NaN;
+ private var heightConstraint:Number = NaN;
/**
* @private
@@ -821,14 +839,14 @@ package spark.components
* that until the next selection is set, either interactively or via the
* API.
*/
- // private var hasProgrammaticSelectionRange:Boolean = false;
+ private var hasProgrammaticSelectionRange:Boolean = false;
/**
* @private
* True if this component sizes itself based on its actual
* contents.
*/
- // mx_internal var autoSize:Boolean = false;
+ mx_internal var autoSize:Boolean = false;
/**
* @private
@@ -843,11 +861,11 @@ package spark.components
/**
* @private
*/
- // private var lastUnscaledWidth:Number;
+ private var lastUnscaledWidth:Number;
/**
* @private
*/
- // private var lastUnscaledHeight:Number;
+ private var lastUnscaledHeight:Number;
//--------------------------------------------------------------------------
//
@@ -874,12 +892,12 @@ package spark.components
/**
* @private
*/
- // private var enabledChanged:Boolean = false;
+ private var enabledChanged:Boolean = false;
/**
* @private
*/
- /* override public function set enabled(value:Boolean):void
+ override public function set enabled(value:Boolean):void
{
if (value == super.enabled)
return;
@@ -889,7 +907,7 @@ package spark.components
invalidateProperties();
invalidateDisplayList();
- } */
+ }
//----------------------------------
// explicitHeight
@@ -934,11 +952,11 @@ package spark.components
/**
* @private
*/
- /* public function get isTruncated():Boolean
+ public function get isTruncated():Boolean
{
// This class does not support truncation
return false;
- } */
+ }
//----------------------------------
// percentHeight
@@ -1009,12 +1027,12 @@ package spark.components
/**
* @private
*/
- //private var _clipAndEnableScrolling:Boolean = false;
+ private var _clipAndEnableScrolling:Boolean = false;
/**
* @private
*/
- //private var clipAndEnableScrollingChanged:Boolean = false;
+ private var clipAndEnableScrollingChanged:Boolean = false;
/**
* @copy spark.core.IViewport#clipAndEnableScrolling
@@ -1026,10 +1044,10 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function get clipAndEnableScrolling():Boolean
+ public function get clipAndEnableScrolling():Boolean
{
return _clipAndEnableScrolling;
- } */
+ }
/**
* @private
@@ -1126,15 +1144,15 @@ package spark.components
/**
* @private
*/
- // private var _horizontalScrollPosition:Number = 0;
+ private var _horizontalScrollPosition:Number = 0;
/**
* @private
*/
- /* private var horizontalScrollPositionChanged:Boolean = false;
+ private var horizontalScrollPositionChanged:Boolean = false;
[Bindable("propertyChange")]
- [Inspectable(defaultValue="0", minValue="0.0")] */
+ [Inspectable(defaultValue="0", minValue="0.0")]
/**
* The number of pixels by which the text is scrolled horizontally.
@@ -1150,15 +1168,15 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function get horizontalScrollPosition():Number
+ public function get horizontalScrollPosition():Number
{
return _horizontalScrollPosition;
- } */
+ }
/**
* @private
*/
- /* public function set horizontalScrollPosition(value:Number):void
+ public function set horizontalScrollPosition(value:Number):void
{
// Convert NaN to 0 to keep TCM happy.
if (isNaN(value))
@@ -1175,7 +1193,7 @@ package spark.components
// Note: TLF takes care of updating the container when the scroll
// position is set so there is no need for us to invalidate the
// display list.
- } */
+ }
//----------------------------------
// verticalScrollPosition
@@ -1184,15 +1202,15 @@ package spark.components
/**
* @private
*/
- //private var _verticalScrollPosition:Number = 0;
+ private var _verticalScrollPosition:Number = 0;
/**
* @private
*/
- /* private var verticalScrollPositionChanged:Boolean = false;
+ private var verticalScrollPositionChanged:Boolean = false;
[Bindable("propertyChange")]
- [Inspectable(defaultValue="0", minValue="0.0")] */
+ [Inspectable(defaultValue="0", minValue="0.0")]
/**
* The number of pixels by which the text is scrolled vertically.
@@ -1208,15 +1226,15 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function get verticalScrollPosition():Number
+ public function get verticalScrollPosition():Number
{
return _verticalScrollPosition;
- } */
+ }
/**
* @private
*/
- /* public function set verticalScrollPosition(value:Number):void
+ public function set verticalScrollPosition(value:Number):void
{
// Convert NaN to 0 to keep TCM happy.
if (isNaN(value))
@@ -1233,7 +1251,7 @@ package spark.components
// Note: TLF takes care of updating the container when the scroll
// position is set so there is no need for us to invalidate the
// display list.
- } */
+ }
//--------------------------------------------------------------------------
//
@@ -1253,7 +1271,7 @@ package spark.components
/**
* @private
*/
- //private var contentChanged:Boolean = false;
+ private var contentChanged:Boolean = false;
/**
* @private
@@ -1331,16 +1349,16 @@ package spark.components
return;
_content = value;
- //contentChanged = true;
- //source = "content";
+ contentChanged = true;
+ source = "content";
// Of 'text', 'textFlow', and 'content', the last one set wins.
- //textChanged = false;
- //textFlowChanged = false;
+ textChanged = false;
+ textFlowChanged = false;
// The other two are now invalid and must be recalculated when needed.
_text = null;
- //_textFlow = null;
+ _textFlow = null;
/*
invalidateProperties();
@@ -1348,7 +1366,13 @@ package spark.components
invalidateDisplayList();
*/
- dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
+ dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
+ if (parent)
+ {
+ commitProperties();
+ //measure();
+ updateDisplayList(getExplicitOrMeasuredWidth(), getExplicitOrMeasuredHeight());
+ }
}
//----------------------------------
@@ -1358,14 +1382,14 @@ package spark.components
/**
* @private
*/
- //private var _displayAsPassword:Boolean = false;
+ private var _displayAsPassword:Boolean = false;
/**
* @private
*/
- /* private var displayAsPasswordChanged:Boolean = false;
+ private var displayAsPasswordChanged:Boolean = false;
- [Inspectable(category="General", defaultValue="false")] */
+ [Inspectable(category="General", defaultValue="false")]
/**
* @copy flash.text.TextField#displayAsPassword
@@ -1375,15 +1399,15 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function get displayAsPassword():Boolean
+ public function get displayAsPassword():Boolean
{
return _displayAsPassword;
- } */
+ }
/**
* @private
*/
- /* public function set displayAsPassword(value:Boolean):void
+ public function set displayAsPassword(value:Boolean):void
{
if (value == _displayAsPassword)
return;
@@ -1394,7 +1418,7 @@ package spark.components
invalidateProperties();
invalidateSize();
invalidateDisplayList();
- } */
+ }
//----------------------------------
// editable
@@ -1408,9 +1432,9 @@ package spark.components
/**
* @private
*/
- /* private var editableChanged:Boolean = false;
+ private var editableChanged:Boolean = false;
- [Inspectable(category="General", defaultValue="true")] */
+ [Inspectable(category="General", defaultValue="true")]
/**
* A flag indicating whether the user is allowed
@@ -1466,7 +1490,7 @@ package spark.components
* Note that this is not a public property
* and does not use the invalidation mechanism.
*/
- /* private function get editingMode():String
+ private function get editingMode():String
{
// Note: this could be called before all properties are committed.
@@ -1480,12 +1504,12 @@ package spark.components
}
return _textContainerManager.editingMode;
- } */
+ }
/**
* @private
*/
- /* private function set editingMode(value:String):void
+ private function set editingMode(value:String):void
{
var lastEditingMode:String = _textContainerManager.editingMode;
@@ -1507,7 +1531,7 @@ package spark.components
_textContainerManager.endInteraction();
}
- } */
+ }
//----------------------------------
// enableIME
@@ -1656,7 +1680,7 @@ package spark.components
// lineBreak
//----------------------------------
- //[Inspectable(environment="none")]
+ [Inspectable(environment="none")]
/**
* @private
@@ -1665,18 +1689,18 @@ package spark.components
* interface. The lineBreak style should be used instead of this
* property.
*/
- /* public function get lineBreak():String
+ public function get lineBreak():String
{
return getStyle("lineBreak");
- } */
+ }
/**
* @private
*/
- /* public function set lineBreak(value:String):void
+ public function set lineBreak(value:String):void
{
setStyle("lineBreak", value);
- } */
+ }
//----------------------------------
// maxChars
@@ -1719,9 +1743,9 @@ package spark.components
/**
* @private
*/
- /* private var _multiline:Boolean = true;
+ private var _multiline:Boolean = true;
- [Inspectable(category="General", defaultValue="true")] */
+ [Inspectable(category="General", defaultValue="true")]
/**
* Determines whether the user can enter multiline text.
@@ -1739,18 +1763,18 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function get multiline():Boolean
+ public function get multiline():Boolean
{
return _multiline;
- } */
+ }
/**
* @private
*/
- /* public function set multiline(value:Boolean):void
+ public function set multiline(value:Boolean):void
{
_multiline = value;
- } */
+ }
//----------------------------------
// restrict
@@ -1759,9 +1783,9 @@ package spark.components
/**
* @private
*/
- /* private var _restrict:String = null;
+ private var _restrict:String = null;
- [Inspectable(category="General", defaultValue="null")] */
+ [Inspectable(category="General", defaultValue="null")]
/**
* @copy flash.text.TextField#restrict
@@ -1773,18 +1797,18 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function get restrict():String
+ public function get restrict():String
{
return _restrict;
- } */
+ }
/**
* @private
*/
- /* public function set restrict(value:String):void
+ public function set restrict(value:String):void
{
_restrict = value;
- } */
+ }
//----------------------------------
// selectable
@@ -1793,14 +1817,14 @@ package spark.components
/**
* @private
*/
- //private var _selectable:Boolean = true;
+ private var _selectable:Boolean = true;
/**
* @private
*/
- /* private var selectableChanged:Boolean = false;
+ private var selectableChanged:Boolean = false;
- [Inspectable(category="General", defaultValue="true")] */
+ [Inspectable(category="General", defaultValue="true")]
/**
* A flag indicating whether the content is selectable
@@ -1819,15 +1843,15 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function get selectable():Boolean
+ public function get selectable():Boolean
{
return _selectable;
- } */
+ }
/**
* @private
*/
- /* public function set selectable(value:Boolean):void
+ public function set selectable(value:Boolean):void
{
if (value == _selectable)
return;
@@ -1837,7 +1861,7 @@ package spark.components
invalidateProperties();
invalidateDisplayList();
- } */
+ }
//----------------------------------
// selectionActivePosition
@@ -1846,10 +1870,10 @@ package spark.components
/**
* @private
*/
- /* private var _selectionActivePosition:int = -1;
+ private var _selectionActivePosition:int = -1;
[Bindable("selectionChange")]
- [Inspectable(category="General", defaultValue="-1")] */
+ [Inspectable(category="General", defaultValue="-1")]
/**
* A character position, relative to the beginning of the
@@ -1876,10 +1900,10 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function get selectionActivePosition():int
+ public function get selectionActivePosition():int
{
return _selectionActivePosition;
- } */
+ }
//----------------------------------
// selectionAnchorPosition
@@ -1888,10 +1912,10 @@ package spark.components
/**
* @private
*/
- /* private var _selectionAnchorPosition:int = -1;
+ private var _selectionAnchorPosition:int = -1;
[Bindable("selectionChange")]
- [Inspectable(category="General", defaultValue="-1")] */
+ [Inspectable(category="General", defaultValue="-1")]
/**
* A character position, relative to the beginning of the
@@ -1918,11 +1942,11 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function get selectionAnchorPosition():int
+ public function get selectionAnchorPosition():int
{
return _selectionAnchorPosition;
- } */
-
+ }
+
//----------------------------------
// selectionHighlighting
//----------------------------------
@@ -2003,7 +2027,7 @@ package spark.components
/**
* @private
*/
- //private var textChanged:Boolean = false;
+ private var textChanged:Boolean = false;
[Bindable("change")]
[Inspectable(category="General", defaultValue="")]
@@ -2115,7 +2139,7 @@ package spark.components
return; */
_text = value;
- /* textChanged = true;
+ textChanged = true;
source = "text";
// Of 'text', 'textFlow', and 'content', the last one set wins.
@@ -2130,7 +2154,13 @@ package spark.components
invalidateSize();
invalidateDisplayList();
- dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); */
+ dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
+ if (parent)
+ {
+ commitProperties();
+ //measure();
+ updateDisplayList(getExplicitOrMeasuredWidth(), getExplicitOrMeasuredHeight());
+ }
}
//----------------------------------
@@ -2140,17 +2170,17 @@ package spark.components
/**
* @private
*/
- // private var _textContainerManager:RichEditableTextContainerManager;
+ private var _textContainerManager:RichEditableTextContainerManager;
/**
* @private
* The TLF TextContainerManager instance that displays,
* scrolls, and edits the text in this component.
*/
- /* mx_internal function get textContainerManager():TextContainerManager
+ mx_internal function get textContainerManager():TextContainerManager
{
return _textContainerManager;
- } */
+ }
//----------------------------------
// textFlow
@@ -2165,7 +2195,7 @@ package spark.components
/**
* @private
*/
- //private var textFlowChanged:Boolean = false;
+ private var textFlowChanged:Boolean = false;
/**
* The TextFlow representing the rich text displayed by this component.
@@ -2227,7 +2257,7 @@ package spark.components
* @productversion Royale 0.9.4
*/
public function get textFlow():TextFlow
- {/*
+ {
// Note: this could be called before all properties are committed.
// We might not have a valid _textFlow for two reasons:
@@ -2242,7 +2272,7 @@ package spark.components
}
else
{
- _textFlow = staticPlainTextImporter.importToFlow(_text);
+ _textFlow = staticPlainTextImporter.importToFlow(_text) as TextFlow;
}
textFlowChanged = true;
}
@@ -2261,7 +2291,6 @@ package spark.components
_textContainerManager.beginInteraction();
_textContainerManager.endInteraction();
}
- */
return _textFlow;
}
@@ -2269,7 +2298,7 @@ package spark.components
* @private
*/
public function set textFlow(value:TextFlow):void
- {/*
+ {
// Treat setting the 'textFlow' to null
// as if 'text' were being set to the empty String
// (which is the default state).
@@ -2299,7 +2328,12 @@ package spark.components
invalidateDisplayList();
dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
- */
+ if (parent)
+ {
+ commitProperties();
+ //measure();
+ updateDisplayList(getExplicitOrMeasuredWidth(), getExplicitOrMeasuredHeight());
+ }
}
//----------------------------------
@@ -2309,20 +2343,20 @@ package spark.components
/**
* @private
*/
- //private var typicalTextChanged:Boolean;
+ private var typicalTextChanged:Boolean;
/**
* @private
*/
- //private var _typicalText:String;
+ private var _typicalText:String;
/**
* @private
* Used when _typicalText is multiline
*/
- /* private var _typicalTextFlow:TextFlow;
+ private var _typicalTextFlow:TextFlow;
- [Inspectable(category="General", defaultValue="null")] */
+ [Inspectable(category="General", defaultValue="null")]
/**
* Text that is used to determine
@@ -2346,15 +2380,15 @@ package spark.components
* @playerversion AIR 2.0
* @productversion Royale 0.9.4
*/
- /* public function get typicalText():String
+ public function get typicalText():String
{
return _typicalText;
- } */
+ }
/**
* @private
*/
- /* public function set typicalText(value:String):void
+ public function set typicalText(value:String):void
{
if (value == _typicalText)
return;
@@ -2366,7 +2400,7 @@ package spark.components
invalidateProperties();
invalidateSize();
invalidateDisplayList();
- } */
+ }
//----------------------------------
// widthInChars
@@ -2521,7 +2555,7 @@ package spark.components
/**
* @private
*/
- /* override protected function commitProperties():void
+ override protected function commitProperties():void
{
super.commitProperties();
@@ -2555,7 +2589,7 @@ package spark.components
// and FTE performance will degrade on a large paragraph.
if (_text.indexOf("\n") != -1 || _text.indexOf("\r") != -1)
{
- _textFlow = staticPlainTextImporter.importToFlow(_text);
+ _textFlow = staticPlainTextImporter.importToFlow(_text) as TextFlow;
_textContainerManager.setTextFlow(_textFlow);
}
else
@@ -2672,9 +2706,9 @@ package spark.components
// from the display list. This causes any accessibilityImplementation that
// was assigned to the component to be removed. The following line restores
// the accessibilityImplementation if it no longer exists.
- if (!accessibilityImplementation)
- initializeAccessibility();
- } */
+ //if (!accessibilityImplementation)
+ // initializeAccessibility();
+ }
/**
* @private
@@ -2903,9 +2937,11 @@ package spark.components
/**
* @private
*/
- /* override protected function updateDisplayList(unscaledWidth:Number,
+ override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
+ TLFFactory.defaultTLFFactory.currentContainer = this;
+
inUpdateDLMethod = true;
//trace("updateDisplayList", unscaledWidth, unscaledHeight, "autoSize", autoSize);
@@ -2980,7 +3016,7 @@ package spark.components
lastUnscaledHeight = unscaledHeight;
inUpdateDLMethod = false;
- } */
+ }
/**
* @private
@@ -3276,10 +3312,10 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function insertText(text:String):void
+ public function insertText(text:String):void
{
handleInsertText(text);
- } */
+ }
/**
* Appends the specified text to the end of the RichEditableText,
@@ -3296,10 +3332,10 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function appendText(text:String):void
+ public function appendText(text:String):void
{
handleInsertText(text, true);
- } */
+ }
/**
* @copy flashx.textLayout.container.ContainerController#scrollToRange()
@@ -3309,14 +3345,14 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function scrollToRange(anchorPosition:int, activePosition:int):void
+ public function scrollToRange(anchorPosition:int, activePosition:int):void
{
// Make sure the properties are commited since the text could change.
validateProperties();
// Scrolls so that the text position is visible in the container.
textContainerManager.scrollToRange(anchorPosition, activePosition);
- } */
+ }
/**
* Selects a specified range of characters.
@@ -3334,7 +3370,7 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function selectRange(anchorPosition:int,
+ public function selectRange(anchorPosition:int,
activePosition:int):void
{
// Make sure the properties are commited since the text could change.
@@ -3366,7 +3402,7 @@ package spark.components
// Remember if the current selection is a range which was set
// programatically.
hasProgrammaticSelectionRange = (anchorPosition != activePosition);
- } */
+ }
/**
* Selects all of the text. This does not include the final paragraph
@@ -3377,10 +3413,10 @@ package spark.components
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* public function selectAll():void
+ public function selectAll():void
{
selectRange(0, int.MAX_VALUE);
- } */
+ }
/**
* Returns a TextLayoutFormat object specifying the computed formats
@@ -3635,17 +3671,17 @@ package spark.components
/**
* @private
*/
- /* mx_internal function createTextContainerManager():RichEditableTextContainerManager
+ mx_internal function createTextContainerManager():RichEditableTextContainerManager
{
return new RichEditableTextContainerManager(this);
- } */
+ }
/**
* @private
*/
- /* private function updateStylesIfChanged():void
+ private function updateStylesIfChanged():void
{
-
+ /*
if (hostFormatChanged)
{
// Side-effect is it marks the text as damaged.
@@ -3682,7 +3718,8 @@ package spark.components
selectionFormatsChanged = false;
}
- } */
+ */
+ }
/**
* @private
@@ -3831,7 +3868,7 @@ package spark.components
* Changing one dimension may change the size of the measured text
* and the layout manager needs to know this.
*/
- /* private function remeasureText(width:Number, height:Number):Boolean
+ private function remeasureText(width:Number, height:Number):Boolean
{
// Neither dimensions changed. If auto-sizing we're still auto-sizing.
if (width == measuredWidth && height == measuredHeight)
@@ -3883,7 +3920,7 @@ package spark.components
remeasuringText = true;
return true;
- } */
+ }
/**
* @private
@@ -4035,7 +4072,7 @@ package spark.components
/**
* @private
*/
- /* private function createTextFlowFromContent(content:Object):TextFlow
+ private function createTextFlowFromContent(content:Object):TextFlow
{
var textFlow:TextFlow ;
@@ -4059,12 +4096,12 @@ package spark.components
}
return textFlow;
- } */
+ }
/**
* @private
*/
- /* private function updateEditingMode():void
+ private function updateEditingMode():void
{
var newEditingMode:String = EditingMode.READ_ONLY;
@@ -4077,14 +4114,14 @@ package spark.components
}
editingMode = newEditingMode;
- } */
+ }
/**
* @private
*
* This is used when text is either inserted or appended via the API.
*/
- /* private function handleInsertText(newText:String, isAppend:Boolean=false):void
+ private function handleInsertText(newText:String, isAppend:Boolean=false):void
{
// Make sure all properties are committed. The damage handler for the
// insert will cause the remeasure and display update.
@@ -4110,7 +4147,7 @@ package spark.components
if (success)
dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
- } */
+ }
/**
* @private
@@ -4626,7 +4663,7 @@ package spark.components
* @private
* Called when the TextContainerManager dispatches a 'selectionChange' event.
*/
- /* private function textContainerManager_selectionChangeHandler(
+ private function textContainerManager_selectionChangeHandler(
event:SelectionEvent):void
{
var oldAnchor:int = _selectionAnchorPosition;
@@ -4657,7 +4694,7 @@ package spark.components
//trace("selectionChangeHandler", _selectionAnchorPosition, _selectionActivePosition);
dispatchEvent(new FlexEvent(FlexEvent.SELECTION_CHANGE));
}
- } */
+ }
/**
* @private
@@ -4900,6 +4937,14 @@ package spark.components
{
TextUtil.recycleTextLine(textLine as TextLine);
} */
+
+ override public function addedToParent():void
+ {
+ super.addedToParent();
+ commitProperties();
+ measure();
+ updateDisplayList(getExplicitOrMeasuredWidth(), getExplicitOrMeasuredHeight());
+ }
}
}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/Scroller.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/Scroller.as
index 4c845ff..2ee8f0d 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/Scroller.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/Scroller.as
@@ -3889,9 +3889,9 @@ public class Scroller extends SkinnableComponent
override public function addedToParent():void
{
super.addedToParent();
- installViewport();
(_viewport as UIComponent).width = width;
(_viewport as UIComponent).height = height;
+ installViewport();
}
}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/TextArea.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/TextArea.as
index bf329f5..e7dd751 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/TextArea.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/TextArea.as
@@ -20,8 +20,10 @@
package spark.components
{
+ import mx.core.IVisualElement;
+
import spark.components.supportClasses.SkinnableTextBase;
-
+
import org.apache.royale.events.Event;
import org.apache.royale.textLayout.elements.TextFlow;
@@ -331,6 +333,17 @@ package spark.components
typeNames += " SparkTextArea";
}
+ override protected function createChildren():void
+ {
+ scroller = new Scroller();
+ scroller.percentHeight = 100;
+ scroller.percentWidth = 100;
+ textDisplay = new RichEditableText();
+ partAdded("textDisplay", textDisplay);
+ scroller.viewport = textDisplay as IVisualElement;
+ addElement(scroller);
+ }
+
//--------------------------------------------------------------------------
//
// Variables
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/RichEditableTextContainerManager.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/RichEditableTextContainerManager.as
new file mode 100644
index 0000000..a5a0b17
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/RichEditableTextContainerManager.as
@@ -0,0 +1,795 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.components.supportClasses
+{
+
+/*
+import flash.display.BlendMode;
+import flash.display.Graphics;
+import flash.events.Event;
+import flash.events.FocusEvent;
+import flash.events.KeyboardEvent;
+import flash.events.MouseEvent;
+import flash.geom.Rectangle;
+import flash.ui.ContextMenu;
+import flash.ui.Keyboard;
+*/
+
+import mx.core.mx_internal;
+/*
+import mx.events.SandboxMouseEvent;
+import mx.styles.IStyleClient;
+*/
+
+import spark.components.RichEditableText;
+/*
+import spark.components.TextSelectionHighlighting;
+
+import flashx.textLayout.tlf_internal;
+import flashx.textLayout.container.ContainerController;
+import flashx.textLayout.edit.EditManager;
+import flashx.textLayout.edit.EditingMode;
+import flashx.textLayout.edit.SelectionFormat;
+import flashx.textLayout.edit.SelectionManager;
+import flashx.textLayout.elements.FlowLeafElement;
+import flashx.textLayout.elements.ParagraphElement;
+import flashx.textLayout.formats.Category;
+import flashx.textLayout.formats.TextLayoutFormat;
+import flashx.textLayout.operations.ApplyFormatOperation;
+import flashx.textLayout.property.Property;
+import flashx.undo.IUndoManager;
+import flashx.undo.UndoManager;
+*/
+
+import org.apache.royale.textLayout.edit.ElementRange;
+import org.apache.royale.textLayout.elements.TextRange;
+import org.apache.royale.textLayout.edit.IEditManager;
+import org.apache.royale.textLayout.edit.ISelectionManager;
+import org.apache.royale.textLayout.elements.IConfiguration;
+import org.apache.royale.textLayout.elements.TextFlow;
+import org.apache.royale.textLayout.formats.ITextLayoutFormat;
+import org.apache.royale.textLayout.operations.InsertTextOperation;
+import org.apache.royale.textLayout.edit.SelectionState;
+import org.apache.royale.textLayout.container.TextContainerManager;
+import org.apache.royale.textLayout.events.SelectionEvent;
+
+use namespace mx_internal;
+
+/*
+use namespace tlf_internal;
+*/
+
+[ExcludeClass]
+
+/**
+ * @private
+ * A subclass of TextContainerManager that manages the text in
+ * a RichEditableText component.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+public class RichEditableTextContainerManager extends TextContainerManager
+{
+ //--------------------------------------------------------------------------
+ //
+ // Class Variables
+ //
+ //--------------------------------------------------------------------------
+ /**
+ * @private
+ * Disables blinking cursor so mustella test snapshots don't get intermittent
+ * cursors.
+ */
+ mx_internal static var hideCursor:Boolean = false;
+
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+ public function RichEditableTextContainerManager(
+ container:RichEditableText,
+ configuration:IConfiguration=null)
+ {
+ super(container, configuration);
+
+ textDisplay = container;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ private var hasScrollRect:Boolean = false;
+
+ /**
+ * @private
+ */
+ private var textDisplay:RichEditableText;
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ override public function drawBackgroundAndSetScrollRect(
+ scrollX:Number, scrollY:Number):Boolean
+ {
+ // If not auto-sizing these are the same as the compositionWidth/Height.
+ // If auto-sizing, the compositionWidth/Height may be NaN. If no
+ // constraints this will reflect the actual size of the text.
+ var width:Number = textDisplay.width;
+ var height:Number = textDisplay.height;
+
+ var contentBounds:Rectangle = getContentBounds();
+
+ // If measuring width, use the content width.
+ if (isNaN(width))
+ width = contentBounds.right;
+
+ // If measuring height, use the content height.
+ if (isNaN(height))
+ height = contentBounds.bottom;
+
+ // TODO:(cframpto) Adjust for RL text.
+ // See ContainerController.updateVisibleRectangle().
+ // (effectiveBlockProgression == BlockProgression.RL) ? -width : 0;
+ var xOrigin:Number = 0;
+
+ // If autoSize, and lineBreak="toFit" there should never be
+ // a scroll rect but if lineBreak="explicit" the text may need
+ // to be clipped.
+ if (scrollX == 0 && scrollY == 0 &&
+ contentBounds.left >= xOrigin &&
+ contentBounds.right <= width &&
+ contentBounds.top >= 0 &&
+ contentBounds.bottom <= height)
+ {
+ // skip the scrollRect
+ if (hasScrollRect)
+ {
+ container.scrollRect = null;
+ hasScrollRect = false;
+ }
+ }
+ else
+ {
+ container.scrollRect = new Rectangle(scrollX, scrollY, width, height);
+ hasScrollRect = true;
+ }
+
+ // Client must draw a background to get mouse events,
+ // even it if is 100% transparent.
+ // If backgroundColor is defined, fill the bounds of the component
+ // with backgroundColor drawn with alpha level backgroundAlpha.
+ // Otherwise, fill with transparent black.
+ // (The color in this case is irrelevant.)
+ var color:uint = 0x000000;
+ var alpha:Number = 0.0;
+ var styleableContainer:IStyleClient = container as IStyleClient;
+ if (styleableContainer)
+ {
+ var backgroundColor:* =
+ styleableContainer.getStyle("backgroundColor");
+ if (backgroundColor !== undefined)
+ {
+ color = uint(backgroundColor);
+ alpha = styleableContainer.getStyle("backgroundAlpha");
+ }
+ }
+ // TODO (cframpto): Adjust for RL text. See
+ // ContainerController.attachTransparentBackgroundForHit().
+ var g:Graphics = container.graphics;
+ g.clear();
+ g.lineStyle();
+ g.beginFill(color, alpha);
+ g.drawRect(scrollX, scrollY, width, height);
+ g.endFill();
+
+ return hasScrollRect;
+ }
+ * */
+
+
+ /**
+ * @private
+ *
+ * If the user specified a custom context menu then use
+ * it rather than the default context menu. It must be set before the
+ * first mouse over/mouse hover or foucsIn event to be used.
+ *
+ * TLF will remove the context menu when it switches from the factory
+ * to the composer and the controller will then request it again.
+ override tlf_internal function getContextMenu():ContextMenu
+ {
+ // ToDo(cframpto): Ideally could specify the context
+ // menu on the TextArea or the TextInput and it wouldn't be obscured
+ // by TLF's context menu.
+
+ // Return null to use the existing contextMenu on the container.
+ // Otherwise the TCM will overwrite this contextMenu.
+ return textDisplay.contextMenu != null ? null : super.getContextMenu();
+ }
+ */
+
+ /**
+ * @private
+ override protected function getUndoManager():IUndoManager
+ {
+ if (!textDisplay.undoManager)
+ {
+ textDisplay.undoManager = new UndoManager();
+ textDisplay.undoManager.undoAndRedoItemLimit = int.MAX_VALUE;
+ }
+
+ return textDisplay.undoManager;
+ }
+ */
+
+ /**
+ * @private
+ override protected function getFocusedSelectionFormat():SelectionFormat
+ {
+ var selectionColor:* = textDisplay.getStyle("focusedTextSelectionColor");
+
+ var focusedPointAlpha:Number =
+ editingMode == EditingMode.READ_WRITE ?
+ 1.0 :
+ 0.0;
+
+ // If editable, the insertion point is black, inverted, which makes it
+ // the inverse color of the background, for maximum readability.
+ // If not editable, then no insertion point.
+ return new SelectionFormat(
+ selectionColor, 1.0, BlendMode.NORMAL,
+ 0x000000, hideCursor ? 0 : focusedPointAlpha, BlendMode.INVERT);
+ }
+ */
+
+ /**
+ * @private
+ override protected function getUnfocusedSelectionFormat():SelectionFormat
+ {
+ var unfocusedSelectionColor:* = textDisplay.getStyle(
+ "unfocusedTextSelectionColor");
+
+ var unfocusedAlpha:Number =
+ textDisplay.selectionHighlighting !=
+ TextSelectionHighlighting.WHEN_FOCUSED ?
+ 1.0 :
+ 0.0;
+
+ // No insertion point when no focus.
+ return new SelectionFormat(
+ unfocusedSelectionColor, unfocusedAlpha, BlendMode.NORMAL,
+ unfocusedSelectionColor, 0.0);
+ }
+ */
+
+ /**
+ * @private
+ override protected function getInactiveSelectionFormat():SelectionFormat
+ {
+ var inactiveSelectionColor:* = textDisplay.getStyle(
+ "inactiveTextSelectionColor");
+
+ var inactivePointAlpha:Number = 0.0;
+
+ var inactiveRangeAlpha:Number =
+ textDisplay.selectionHighlighting ==
+ TextSelectionHighlighting.ALWAYS ?
+ 1.0 :
+ 0.0;
+
+
+ // This doesn't really matter since inactivePointAlpha is 0.
+ var pointBlinkRate:Number = 0.0;
+
+ return new SelectionFormat(
+ inactiveSelectionColor, inactiveRangeAlpha, BlendMode.NORMAL,
+ inactiveSelectionColor, inactivePointAlpha, BlendMode.INVERT,
+ pointBlinkRate);
+ }
+ */
+
+ /**
+ * @private
+ override protected function createEditManager(
+ undoManager:flashx.undo.IUndoManager):IEditManager
+ {
+ var editManager:IEditManager = super.createEditManager(undoManager);
+
+ // Default is to batch text input. If the component, like ComboBox
+ // wants to act on each keystroke then set this to false.
+ editManager.allowDelayedOperations = textDisplay.batchTextInput;
+
+ // Do not delayUpdates until further work is done to ensure our public API methods to
+ // format and insert text work correctly. TLF does not dispatch the selectionChange
+ // event until the display is updated which means our selection properties may not
+ // be in sync with the TLF values. This could matter for our API methods that
+ // take the selection as parameters or default to the current selection. In the
+ // former case, the user could query for the selection or rely on the selectionChange
+ // event and get incorrect values if there is a pending update and in the later case
+ // we fill in the default selection which might not be current if there is a pending
+ // update.
+ editManager.delayUpdates = false;
+
+ return editManager;
+ }
+ */
+
+ /**
+ * @private
+ */
+ override public function setText(text:String):void
+ {
+ super.setText(text);
+
+ // If we have focus, need to make sure we can still input text.
+ //initForInputIfHaveFocus();
+ }
+
+ /**
+ * @private
+ */
+ override public function setTextFlow(textFlow:TextFlow):void
+ {
+ super.setTextFlow(textFlow);
+
+ // If we have focus, need to make sure we can still input text.
+ //initForInputIfHaveFocus();
+ }
+
+ /**
+ * @private
+ private function initForInputIfHaveFocus():void
+ {
+ // If we have focus, need to make sure there is a composer in place,
+ // the new controller knows it has focus, and there is an insertion
+ // point so input works without a mouse over or mouse click. Normally
+ // this is done in our focusIn handler by making sure there is a
+ // selection. Test this by clicking an arrow in the NumericStepper
+ // and then entering a number without clicking on the input field first.
+ if (editingMode != EditingMode.READ_ONLY &&
+ textDisplay.getFocus() == textDisplay)
+ {
+ // this will ensure a text flow with a comopser
+ var im:ISelectionManager = beginInteraction();
+
+ var controller:ContainerController =
+ getTextFlow().flowComposer.getControllerAt(0);
+
+ controller.requiredFocusInHandler(null);
+
+ if (!preserveSelectionOnSetText)
+ im.selectRange(0, 0);
+
+ endInteraction();
+ }
+ }
+ */
+
+ /**
+ * @private
+ * To apply a format to a selection in a textFlow without using the
+ * selection manager.
+ mx_internal function applyFormatOperation(
+ leafFormat:ITextLayoutFormat,
+ paragraphFormat:ITextLayoutFormat,
+ containerFormat:ITextLayoutFormat,
+ anchorPosition:int,
+ activePosition:int):Boolean
+ {
+ // Nothing to do.
+ if (anchorPosition == -1 || activePosition == -1)
+ return true;
+
+ var textFlow:TextFlow = getTextFlowWithComposer();
+
+ var operationState:SelectionState =
+ new SelectionState(textFlow, anchorPosition, activePosition);
+
+ // If using the edit manager and the selection is the current selection,
+ // need to set the flag so point selection is set with pending formats for next
+ // char typed.
+ const editManager:IEditManager = textFlow.interactionManager as IEditManager;
+ if (editManager)
+ {
+ const absoluteStart:int = getAbsoluteStart(anchorPosition, activePosition);
+ const absoluteEnd:int = getAbsoluteEnd(anchorPosition, activePosition);
+
+ if (editManager.absoluteStart == absoluteStart && editManager.absoluteEnd == absoluteEnd)
+ operationState.selectionManagerOperationState = true;
+ }
+
+ // For the case when interactive editing is not allowed.
+ var op:ApplyFormatOperation =
+ new ApplyFormatOperation(
+ operationState, leafFormat, paragraphFormat, containerFormat);
+
+ var success:Boolean = op.doOperation();
+ if (success)
+ {
+ textFlow.normalize();
+ textFlow.flowComposer.updateAllControllers();
+ }
+
+ return success;
+ }
+ */
+
+ /**
+ * @private
+ * To get the format of a character. Our API allows this operation even
+ * when the editingMode does not permit either interactive selection or
+ * editing.
+ */
+ mx_internal function getCommonCharacterFormat(
+ anchorPosition:int,
+ activePosition:int):ITextLayoutFormat
+ {
+ if (anchorPosition == -1 || activePosition == -1)
+ return null;
+
+ var textFlow:TextFlow = getTextFlowWithComposer();
+
+ if (textFlow.interactionManager)
+ {
+ // If there is a selection manager use it so that the format,
+ // depending on the range, may include any attributes set on a point
+ // selection but not yet applied.
+ const range:TextRange =
+ new TextRange(textFlow, anchorPosition, activePosition);
+
+ return textFlow.interactionManager.getCommonCharacterFormat(range);
+ }
+ else
+ {
+ // ElementRange will order the selection points. Since there isn't
+ // an interactionManager there is not a point selection to worry
+ // about.
+ var selRange:ElementRange =
+ ElementRange.createElementRange(textFlow, anchorPosition, activePosition);
+
+ return selRange.getCommonCharacterFormat();
+ }
+ }
+
+ /**
+ * @private
+ * To get the format of the container without using a SelectionManager.
+ * The method should be kept in sync with the version in the
+ * SelectionManager.
+ mx_internal function getCommonContainerFormat():ITextLayoutFormat
+ {
+ var textFlow:TextFlow = getTextFlowWithComposer();
+
+ // absoluteStart and absoluteEnd values not used.
+ var selRange:ElementRange =
+ ElementRange.createElementRange(textFlow, 0, textFlow.textLength - 1);
+
+ return selRange.getCommonContainerFormat();
+ }
+ */
+
+ /**
+ * @private
+ * To get the format of a paragraph without using a SelectionManager.
+ * The method should be kept in sync with the version in the
+ * SelectionManager.
+ mx_internal function getCommonParagraphFormat(
+ anchorPosition:int,
+ activePosition:int):ITextLayoutFormat
+ {
+ if (anchorPosition == -1 || activePosition == -1)
+ return null;
+
+ var textFlow:TextFlow = getTextFlowWithComposer();
+
+ // ElementRange will order the selection points.
+ var selRange:ElementRange =
+ ElementRange.createElementRange(textFlow, anchorPosition, activePosition);
+
+ return selRange.getCommonParagraphFormat();
+ }
+ */
+
+ /**
+ * @private
+ * Insert or append text to the textFlow without using an EditManager.
+ * If there is a SelectionManager or EditManager its selection will be
+ * updated at the end of the operation to keep it in sync.
+ */
+ mx_internal function insertTextOperation(insertText:String,
+ anchorPosition:int,
+ activePosition:int):Boolean
+ {
+ // No insertion point.
+ if (anchorPosition == -1 || activePosition == -1)
+ return false;
+
+ var textFlow:TextFlow = getTextFlowWithComposer();
+
+ var absoluteStart:int = getAbsoluteStart(anchorPosition, activePosition);
+ var absoluteEnd:int = getAbsoluteEnd(anchorPosition, activePosition);
+
+ // Need to get the format of the insertion point so that the inserted
+ // text will have this format.
+ var pointFormat:ITextLayoutFormat =
+ getCommonCharacterFormat(absoluteStart, absoluteStart);
+
+ var operationState:SelectionState =
+ new SelectionState(textFlow, absoluteStart, absoluteEnd, pointFormat);
+
+ // If there is an interaction manager, this keeps it in sync with
+ // the results of this operation.
+ operationState.selectionManagerOperationState = true;
+
+ var op:InsertTextOperation =
+ new InsertTextOperation(operationState, insertText);
+
+ // Generations don't seem to be used in this code path since we
+ // aren't doing composite, merge or undo operations so they were
+ // optimized out.
+
+ var success:Boolean = op.doOperation();
+ if (success)
+ {
+ textFlow.normalize();
+
+ textFlow.flowComposer.updateAllControllers();
+
+ var insertPt:int = absoluteEnd - (absoluteEnd - absoluteStart) +
+ + insertText.length;
+
+ // No point format.
+ var selectionState:SelectionState =
+ new SelectionState(textFlow, insertPt, insertPt);
+
+ var selectionEvent:SelectionEvent =
+ new SelectionEvent(SelectionEvent.SELECTION_CHANGE,
+ false, false, selectionState);
+
+ textFlow.dispatchEvent(selectionEvent);
+
+ scrollToRange(insertPt, insertPt);
+ }
+
+ return success;
+ }
+
+ /**
+ * Note: It is probably a TLF bug that, if delayedUpdates is true, we have to call
+ * updateAllControllers before doing a format operation to guarantee the correct
+ * results.
+ */
+ mx_internal function getTextFlowWithComposer():TextFlow
+ {
+ var textFlow:TextFlow = getTextFlow() as TextFlow;
+
+ // Make sure there is a text flow with a flow composer. There will
+ // not be an interaction manager if editingMode is read-only. If
+ // there is an interaction manager flush any pending inserts into the
+ // text flow unless we are delaying updates in which case we may have to finish
+ // composition.
+ if (composeState != TextContainerManager.COMPOSE_COMPOSER)
+ {
+ convertToTextFlowWithComposer();
+ }
+ else if (textFlow.interactionManager)
+ {
+ const editManager:IEditManager = textFlow.interactionManager as IEditManager;
+ if (editManager && editManager.delayUpdates)
+ editManager.updateAllControllers();
+ else
+ textFlow.interactionManager.flushPendingOperations();
+ }
+
+ return textFlow;
+ }
+
+ /**
+ * @private
+ */
+ private function getAbsoluteStart(anchorPosition:int, activePosition:int):int
+ {
+ return (anchorPosition < activePosition) ?
+ anchorPosition : activePosition;
+ }
+
+ /**
+ * @private
+ */
+ private function getAbsoluteEnd(anchorPosition:int, activePosition:int):int
+ {
+ return (anchorPosition > activePosition) ?
+ anchorPosition : activePosition;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden event handlers
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ override public function focusInHandler(event:FocusEvent):void
+ {
+ textDisplay.focusInHandler(event);
+
+ super.focusInHandler(event);
+ }
+ */
+
+ /**
+ * @private
+ override public function focusOutHandler(event:FocusEvent):void
+ {
+ textDisplay.focusOutHandler(event);
+
+ super.focusOutHandler(event);
+ }
+ */
+
+ /**
+ * @private
+ override public function keyDownHandler(event:KeyboardEvent):void
+ {
+ textDisplay.keyDownHandler(event);
+
+ if (!event.isDefaultPrevented())
+ {
+ var clone:KeyboardEvent = KeyboardEvent(event.clone());
+ super.keyDownHandler(clone);
+ if (clone.isDefaultPrevented())
+ event.preventDefault();
+ }
+ }
+ */
+
+ /**
+ * @private
+ override public function keyUpHandler(event:KeyboardEvent):void
+ {
+ if (!event.isDefaultPrevented())
+ {
+ var clone:KeyboardEvent = KeyboardEvent(event.clone());
+ super.keyUpHandler(clone);
+ if (clone.isDefaultPrevented())
+ event.preventDefault();
+ }
+ }
+ */
+
+ /**
+ * @private
+ override public function mouseDownHandler(event:MouseEvent):void
+ {
+ textDisplay.mouseDownHandler(event);
+
+ super.mouseDownHandler(event);
+ }
+ */
+
+ /**
+ * @private
+ * This handler gets called for ACTIVATE events from the player
+ * and FLEX_WINDOW_ACTIVATE events from Flex. Because of the
+ * way AIR handles activation of AIR Windows, and because Flex
+ * has its own concept of popups or pseudo-windows, we
+ * ignore ACTIVATE and respond to FLEX_WINDOW_ACTIVATE instead
+ override public function activateHandler(event:Event):void
+ {
+ // block ACTIVATE events
+ if (event.type == Event.ACTIVATE)
+ return;
+
+ super.activateHandler(event);
+
+ // TLF ties activation and focus together. If a Flex PopUp is created
+ // it is possible to get deactivate/activate events without any
+ // focus events. If we have focus when we are activated, the selection
+ // state should be SelectionFormatState.FOCUSED not
+ // SelectionFormatState.UNFOCUSED since there might not be a follow on
+ // focusIn event.
+ if (editingMode != EditingMode.READ_ONLY &&
+ textDisplay.getFocus() == textDisplay)
+ {
+ var im:SelectionManager = SelectionManager(beginInteraction());
+ im.setFocus();
+ endInteraction();
+ }
+ }
+ */
+
+ /**
+ * @private
+ * This handler gets called for DEACTIVATE events from the player
+ * and FLEX_WINDOW_DEACTIVATE events from Flex. Because of the
+ * way AIR handles activation of AIR Windows, and because Flex
+ * has its own concept of popups or pseudo-windows, we
+ * ignore DEACTIVATE and respond to FLEX_WINDOW_DEACTIVATE instead
+ override public function deactivateHandler(event:Event):void
+ {
+ // block DEACTIVATE events
+ if (event.type == Event.DEACTIVATE)
+ return;
+
+ super.deactivateHandler(event);
+ }
+ */
+
+ /**
+ * @private
+ * sandbox support
+ override public function beginMouseCapture():void
+ {
+ super.beginMouseCapture();
+ textDisplay.systemManager.getSandboxRoot().addEventListener(SandboxMouseEvent.MOUSE_UP_SOMEWHERE, mouseUpSomewhereHandler);
+ textDisplay.systemManager.getSandboxRoot().addEventListener(SandboxMouseEvent.MOUSE_MOVE_SOMEWHERE, mouseMoveSomewhereHandler);
+ }
+ */
+
+ /**
+ * @private
+ * sandbox support
+ override public function endMouseCapture():void
+ {
+ super.endMouseCapture();
+ textDisplay.systemManager.getSandboxRoot().removeEventListener(SandboxMouseEvent.MOUSE_UP_SOMEWHERE, mouseUpSomewhereHandler);
+ textDisplay.systemManager.getSandboxRoot().removeEventListener(SandboxMouseEvent.MOUSE_MOVE_SOMEWHERE, mouseMoveSomewhereHandler);
+ }
+ */
+
+ //--------------------------------------------------------------------------
+ //
+ // Event handlers
+ //
+ //--------------------------------------------------------------------------
+
+ /*
+ private function mouseUpSomewhereHandler(event:Event):void
+ {
+ mouseUpSomewhere(event);
+ }
+
+ private function mouseMoveSomewhereHandler(event:Event):void
+ {
+ mouseMoveSomewhere(event);
+ }
+ */
+}
+
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableTextBase.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableTextBase.as
index 4d262d3..0735fa3 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableTextBase.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableTextBase.as
@@ -31,13 +31,11 @@ import flash.events.SoftKeyboardEvent;
import flash.system.Capabilities;
import flashx.textLayout.elements.TextFlow;
-import flashx.textLayout.events.SelectionEvent;
import mx.core.FlexGlobals;
import mx.core.IIMESupport;
import mx.core.IVisualElement;
import mx.core.InteractionMode;
-import mx.events.FlexEvent;
import mx.events.SandboxMouseEvent;
import mx.events.TouchInteractionEvent;
import mx.utils.Platform;
@@ -47,19 +45,21 @@ import spark.components.TextSelectionHighlighting;
import spark.core.IDisplayText;
import spark.core.IProxiedStageTextWrapper;
import spark.core.ISoftKeyboardHintClient;
-import spark.events.TextOperationEvent;
*/
+import mx.events.FlexEvent;
import mx.core.mx_internal;
import mx.managers.IFocusManagerComponent;
import mx.utils.BitFlagUtil;
import spark.components.RichEditableText;
import spark.core.IEditableText;
+import spark.events.TextOperationEvent;
import org.apache.royale.events.Event;
import org.apache.royale.events.MouseEvent;
import org.apache.royale.html.accessories.PasswordInputBead;
import org.apache.royale.textLayout.elements.TextFlow;
+import org.apache.royale.textLayout.events.SelectionEvent;
use namespace mx_internal;
@@ -332,52 +332,52 @@ public class SkinnableTextBase extends SkinnableComponent
/**
* @private
*/
- // private static const DISPLAY_AS_PASSWORD_PROPERTY_FLAG:uint = 1 << 1;
+ private static const DISPLAY_AS_PASSWORD_PROPERTY_FLAG:uint = 1 << 1;
/**
* @private
*/
- // private static const EDITABLE_PROPERTY_FLAG:uint = 1 << 2;
+ private static const EDITABLE_PROPERTY_FLAG:uint = 1 << 2;
/**
* @private
*/
- // private static const HEIGHT_IN_LINES_PROPERTY_FLAG:uint = 1 << 3;
+ private static const HEIGHT_IN_LINES_PROPERTY_FLAG:uint = 1 << 3;
/**
* @private
*/
- // private static const IME_MODE_PROPERTY_FLAG:uint = 1 << 4;
+ private static const IME_MODE_PROPERTY_FLAG:uint = 1 << 4;
/**
* @private
*/
- // private static const MAX_CHARS_PROPERTY_FLAG:uint = 1 << 5;
+ private static const MAX_CHARS_PROPERTY_FLAG:uint = 1 << 5;
/**
* @private
*/
- // private static const MAX_WIDTH_PROPERTY_FLAG:uint = 1 << 7;
+ private static const MAX_WIDTH_PROPERTY_FLAG:uint = 1 << 7;
/**
* @private
*/
- // private static const RESTRICT_PROPERTY_FLAG:uint = 1 << 8;
+ private static const RESTRICT_PROPERTY_FLAG:uint = 1 << 8;
/**
* @private
*/
- // private static const SELECTABLE_PROPERTY_FLAG:uint = 1 << 9;
+ private static const SELECTABLE_PROPERTY_FLAG:uint = 1 << 9;
/**
* @private
*/
- // private static const SELECTION_HIGHLIGHTING_FLAG:uint = 1 << 10;
+ private static const SELECTION_HIGHLIGHTING_FLAG:uint = 1 << 10;
/**
* @private
*/
- // private static const TEXT_PROPERTY_FLAG:uint = 1 << 11;
+ private static const TEXT_PROPERTY_FLAG:uint = 1 << 11;
/**
* @private
@@ -387,37 +387,37 @@ public class SkinnableTextBase extends SkinnableComponent
/**
* @private
*/
- // private static const TYPICAL_TEXT_PROPERTY_FLAG:uint = 1 << 13;
+ private static const TYPICAL_TEXT_PROPERTY_FLAG:uint = 1 << 13;
/**
* @private
*/
- // private static const WIDTH_IN_CHARS_PROPERTY_FLAG:uint = 1 << 14;
+ private static const WIDTH_IN_CHARS_PROPERTY_FLAG:uint = 1 << 14;
/**
* @private
*/
- // private static const AUTO_CAPITALIZE_FLAG:uint = 1 << 15;
+ private static const AUTO_CAPITALIZE_FLAG:uint = 1 << 15;
/**
* @private
*/
- // private static const AUTO_CORRECT_FLAG:uint = 1 << 16;
+ private static const AUTO_CORRECT_FLAG:uint = 1 << 16;
/**
* @private
*/
- // private static const RETURN_KEY_LABEL_FLAG:uint = 1 << 17;
+ private static const RETURN_KEY_LABEL_FLAG:uint = 1 << 17;
/**
* @private
*/
- // private static const SOFT_KEYBOARD_TYPE_FLAG:uint = 1 << 18;
+ private static const SOFT_KEYBOARD_TYPE_FLAG:uint = 1 << 18;
/**
* @private
*/
- // private static const PROMPT_TEXT_PROPERTY_FLAG:uint = 1;
+ private static const PROMPT_TEXT_PROPERTY_FLAG:uint = 1;
//--------------------------------------------------------------------------
//
@@ -1504,7 +1504,7 @@ public class SkinnableTextBase extends SkinnableComponent
*/
public function get text():String
{
- /* if (textDisplay)
+ if (textDisplay)
return textDisplay.text;
// If there is no textDisplay, it isn't possible to set one of
@@ -1512,8 +1512,7 @@ public class SkinnableTextBase extends SkinnableComponent
// want the default to be the empty string
var v:* = textDisplayProperties.text;
- return (v === undefined) ? "" : v; */
- return "";
+ return (v === undefined) ? "" : v;
}
/**
@@ -1523,7 +1522,7 @@ public class SkinnableTextBase extends SkinnableComponent
{
// text should never be null. Convert null to the empty string.
- /* if (textDisplay)
+ if (textDisplay)
{
textDisplay.text = value;
textDisplayProperties = BitFlagUtil.update(
@@ -1542,7 +1541,7 @@ public class SkinnableTextBase extends SkinnableComponent
// Generate an UPDATE_COMPLETE event.
invalidateProperties();
- invalidateSkinState(); */
+ invalidateSkinState();
}
//----------------------------------
@@ -1860,10 +1859,11 @@ public class SkinnableTextBase extends SkinnableComponent
/**
* @private
*/
- /* override protected function partAdded(partName:String, instance:Object):void
+ override protected function partAdded(partName:String, instance:Object):void
{
super.partAdded(partName, instance);
+ /*
if (instance == promptDisplay)
{
var newPromptDisplayProperties:uint = 0;
@@ -1875,7 +1875,7 @@ public class SkinnableTextBase extends SkinnableComponent
}
promptDisplayProperties = newPromptDisplayProperties;
}
-
+ */
if (instance == textDisplay)
{
// Copy proxied values from textDisplayProperties (if set) to
@@ -1902,7 +1902,7 @@ public class SkinnableTextBase extends SkinnableComponent
textDisplay.addEventListener(FlexEvent.VALUE_COMMIT,
textDisplay_valueCommitHandler);
}
- } */
+ }
/**
* @private
@@ -2351,7 +2351,7 @@ public class SkinnableTextBase extends SkinnableComponent
* Copy values stored locally into textDisplay now that textDisplay
* has been added.
*/
- /* private function textDisplayAdded():void
+ private function textDisplayAdded():void
{
var newTextDisplayProperties:uint = 0;
var richEditableText:RichEditableText = textDisplay as RichEditableText;
@@ -2387,12 +2387,13 @@ public class SkinnableTextBase extends SkinnableComponent
HEIGHT_IN_LINES_PROPERTY_FLAG, true);
}
+ /*
if (textDisplayProperties.imeMode !== undefined && richEditableText)
{
richEditableText.imeMode = textDisplayProperties.imeMode;
newTextDisplayProperties = BitFlagUtil.update(
uint(newTextDisplayProperties), IME_MODE_PROPERTY_FLAG, true);
- }
+ }*/
if (textDisplayProperties.maxChars !== undefined)
{
@@ -2425,6 +2426,7 @@ public class SkinnableTextBase extends SkinnableComponent
uint(newTextDisplayProperties), SELECTABLE_PROPERTY_FLAG, true);
}
+ /*
if (textDisplayProperties.selectionHighlighting !== undefined && richEditableText)
{
richEditableText.selectionHighlighting =
@@ -2432,7 +2434,7 @@ public class SkinnableTextBase extends SkinnableComponent
newTextDisplayProperties = BitFlagUtil.update(
uint(newTextDisplayProperties),
SELECTION_HIGHLIGHTING_FLAG, true);
- }
+ }*/
if (textDisplayProperties.text != null)
{
@@ -2464,6 +2466,7 @@ public class SkinnableTextBase extends SkinnableComponent
WIDTH_IN_CHARS_PROPERTY_FLAG, true);
}
+ /*
var softKeyboardClient:ISoftKeyboardHintClient = textDisplay as ISoftKeyboardHintClient;
if (textDisplayProperties.autoCapitalize !== undefined && softKeyboardClient)
@@ -2497,10 +2500,11 @@ public class SkinnableTextBase extends SkinnableComponent
uint(newTextDisplayProperties),
SOFT_KEYBOARD_TYPE_FLAG, true);
}
+ */
// Switch from storing properties to bit mask of stored properties.
textDisplayProperties = newTextDisplayProperties;
- } */
+ }
/**
* @private
@@ -2795,11 +2799,11 @@ public class SkinnableTextBase extends SkinnableComponent
* @private
* Called when the RichEditableText dispatches a 'selectionChange' event.
*/
- /* private function textDisplay_selectionChangeHandler(event:Event):void
+ private function textDisplay_selectionChangeHandler(event:Event):void
{
// Redispatch the event that came from the RichEditableText.
dispatchEvent(event);
- } */
+ }
/**
* Called when the RichEditableText dispatches a 'change' event
@@ -2810,12 +2814,13 @@ public class SkinnableTextBase extends SkinnableComponent
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- /* private function textDisplay_changeHandler(event:Event):void
+ private function textDisplay_changeHandler(event:Event):void
{
// The text component has changed. Generate an UPDATE_COMPLETE event.
invalidateDisplayList();
+ /*
// We may have gone from empty to non-empty or vice-versa. This should
// cause the prompt to show or hide.
if (prompt != null && prompt != "" && skin && skin.currentState)
@@ -2827,21 +2832,21 @@ public class SkinnableTextBase extends SkinnableComponent
invalidateSkinState();
}
}
-
+ */
// Redispatch the event that came from the RichEditableText.
dispatchEvent(event);
- } */
+ }
/**
* @private
* Called when the RichEditableText dispatches a 'changing' event
* before an editing operation.
*/
- /* private function textDisplay_changingHandler(event:TextOperationEvent):void
+ private function textDisplay_changingHandler(event:TextOperationEvent):void
{
// Redispatch the event that came from the RichEditableText.
- var newEvent:Event = event.clone();
+ var newEvent:Event = event.cloneEvent();
dispatchEvent(newEvent);
// If the event dispatched from this component is canceled,
@@ -2849,18 +2854,18 @@ public class SkinnableTextBase extends SkinnableComponent
// the editing operation from being processed.
if (newEvent.isDefaultPrevented())
event.preventDefault();
- } */
+ }
/**
* @private
* Called when the RichEditableText dispatches an 'enter' event
* in response to the Enter key.
*/
- /* private function textDisplay_enterHandler(event:Event):void
+ private function textDisplay_enterHandler(event:Event):void
{
// Redispatch the event that came from the RichEditableText.
dispatchEvent(event);
- } */
+ }
/**
* @private
@@ -2871,11 +2876,11 @@ public class SkinnableTextBase extends SkinnableComponent
* there isn't a textDisplay since since the event will be dispatched by
* RET when the textDisplay part is added.
*/
- /* private function textDisplay_valueCommitHandler(event:Event):void
+ private function textDisplay_valueCommitHandler(event:Event):void
{
// Redispatch the event that came from the RichEditableText.
dispatchEvent(event);
- } */
+ }
override public function setStyle(styleName:String, value:*):void
{