FLEX-33698 Added support for shift-return with three levels:
0 Always hard return
1 hard return in lists
2 always soft return (deault)
diff --git a/textLayout/src/flashx/textLayout/edit/EditManager.as b/textLayout/src/flashx/textLayout/edit/EditManager.as
index 645e79e..2b46e72 100644
--- a/textLayout/src/flashx/textLayout/edit/EditManager.as
+++ b/textLayout/src/flashx/textLayout/edit/EditManager.as
@@ -138,6 +138,7 @@
*/
public class EditManager extends SelectionManager implements IEditManager
{
+ static tlf_internal var handleShiftAsSoftReturn:Boolean = true;
/**
* To minimize expensive recompositions during fast typing, inserts
* don't necessarily take place immediately. An insert operation that
@@ -306,8 +307,14 @@
/* pre-Argo and on the mac then ignoreNextTextEvent */
if (!Configuration.versionIsAtLeast(10,1) && (Capabilities.os.search("Mac OS") > -1))
ignoreNextTextEvent = true;
- undo();
- event.preventDefault();
+ if(event.shiftKey){
+ redo();
+ event.preventDefault();
+
+ } else {
+ undo();
+ event.preventDefault();
+ }
break;
case 121: // small y
ignoreNextTextEvent = true;
@@ -383,7 +390,7 @@
if (listItem && firstLeaf.getParentByType(ListElement) != listItem.getParentByType(ListElement))
listItem = null;
- // inside a list shift-enter splits a paragraph and shift splits the listitem
+ // inside a list shift-enter splits a paragraph and enter splits the listitem
if (listItem && !event.shiftKey)
{
// if on last item of list and it's empty, remove it and put cursor on a new para immediatly following the list (new para should be wrapped in a new list item if parent of list is another list).
@@ -403,6 +410,13 @@
refreshSelection();
}
}
+ else if(event.shiftKey &&
+ ((!listItem && textFlow.configuration.shiftEnterLevel > 0) ||
+ textFlow.configuration.shiftEnterLevel > 1)
+ )
+ {
+ overwriteMode ? overwriteText("\u2028") : insertText("\u2028");
+ }
else
splitParagraph();
event.preventDefault();
diff --git a/textLayout/src/flashx/textLayout/elements/Configuration.as b/textLayout/src/flashx/textLayout/elements/Configuration.as
index 64af033..c9c3cf4 100644
--- a/textLayout/src/flashx/textLayout/elements/Configuration.as
+++ b/textLayout/src/flashx/textLayout/elements/Configuration.as
@@ -71,10 +71,18 @@
static tlf_internal const playerEnablesSpicyFeatures:Boolean = versionIsAtLeast(10,2) && (new Sprite).hasOwnProperty("needsSoftKeyboard");
static tlf_internal const hasTouchScreen:Boolean = playerEnablesArgoFeatures && Capabilities["touchScreenType"] != "none";
+ static public const SHIFT_RETURN_AS_HARD:int = 0;
+ static public const SHIFT_RETURN_AS_HARD_IN_LIST:int = 1;
+ static public const SHIFT_RETURN_AS_SOFT:int = 2;
+
+ static tlf_internal var defaultShiftEnterLevel:int = SHIFT_RETURN_AS_SOFT;
+
/** If manageTabKey and manageEnterKey are false, the client must handle those keys on their own. */
private var _manageTabKey:Boolean;
private var _manageEnterKey:Boolean;
+ private var _shiftEnterLevel:int = defaultShiftEnterLevel;
+
private var _overflowPolicy:String;
private var _enableAccessibility:Boolean;
@@ -250,7 +258,18 @@
public function set manageEnterKey(value:Boolean):void
{ _manageEnterKey = value; _immutableClone = null; }
-
+ /**
+ * @copy IConfiguration#shiftEnterLevel
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+
+ public function get shiftEnterLevel():int
+ { return _shiftEnterLevel; }
+ public function set shiftEnterLevel(value:int):void
+ { _shiftEnterLevel = value; }
/**
* @copy IConfiguration#overflowPolicy
diff --git a/textLayout/src/flashx/textLayout/elements/IConfiguration.as b/textLayout/src/flashx/textLayout/elements/IConfiguration.as
index 721e6ce..6a06016 100644
--- a/textLayout/src/flashx/textLayout/elements/IConfiguration.as
+++ b/textLayout/src/flashx/textLayout/elements/IConfiguration.as
@@ -66,6 +66,20 @@
function get manageEnterKey():Boolean
/**
+ * Determines how shift-enter is treated. Shift-enter can be treated as a soft return or hard return.
+ * There are three possible levels. Level 0 means all shift-returns will be hard returns.
+ * Level 1 means shift-returns inside lists will be treated as hard returns. Otherwise they will be treated as hard returns.
+ * Level 2 means all shift-returns will be treated as soft returns.
+ *
+ * <p>Default value is <code>2</code>.</p>
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+
+ function get shiftEnterLevel():int;
+ /**
* Policy used for deciding whether the last line of a container fits in the container, or whether it overflows.
* Use the constants of the OverflowPolicy class to set this property.
*
diff --git a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
index 13590a5..f8fea72 100644
--- a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
+++ b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
@@ -482,7 +482,7 @@
{
var textBlock:TextBlock = getTextBlock();
var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
- var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
+ var currentAtomIndex:int = tl.getAtomIndexAtCharIndex(relativePosition);
if (currentAtomIndex == 0)
{
tl = tl.previousLine;
@@ -524,7 +524,7 @@
{
var textBlock:TextBlock = getTextBlock();
var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
- var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
+ var currentAtomIndex:int = tl.getAtomIndexAtCharIndex(relativePosition);
if (currentAtomIndex == tl.atomCount - 1)
{
tl = tl.nextLine;