You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2013/10/12 01:11:53 UTC
[2/3] git commit: [flex-tlf] [refs/heads/master] - FLEX-33698 Added
support for shift-return with three levels: 0 Always hard return 1 hard
return in lists 2 always soft return (deault)
FLEX-33698 Added support for shift-return with three levels:
0 Always hard return
1 hard return in lists
2 always soft return (deault)
Project: http://git-wip-us.apache.org/repos/asf/flex-tlf/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-tlf/commit/258787a7
Tree: http://git-wip-us.apache.org/repos/asf/flex-tlf/tree/258787a7
Diff: http://git-wip-us.apache.org/repos/asf/flex-tlf/diff/258787a7
Branch: refs/heads/master
Commit: 258787a70bf31eaeca81b5fe98f2fe7b9559e4eb
Parents: f4545d2
Author: Harbs <ha...@in-tools.com>
Authored: Tue Sep 3 15:05:56 2013 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Tue Sep 3 15:05:56 2013 +0300
----------------------------------------------------------------------
.../src/flashx/textLayout/edit/EditManager.as | 20 ++++++++++++++++---
.../flashx/textLayout/elements/Configuration.as | 21 +++++++++++++++++++-
.../textLayout/elements/IConfiguration.as | 14 +++++++++++++
.../textLayout/elements/ParagraphElement.as | 4 ++--
4 files changed, 53 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/258787a7/textLayout/src/flashx/textLayout/edit/EditManager.as
----------------------------------------------------------------------
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 @@ package flashx.textLayout.edit
*/
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 @@ package flashx.textLayout.edit
/* 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 @@ package flashx.textLayout.edit
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 @@ package flashx.textLayout.edit
refreshSelection();
}
}
+ else if(event.shiftKey &&
+ ((!listItem && textFlow.configuration.shiftEnterLevel > 0) ||
+ textFlow.configuration.shiftEnterLevel > 1)
+ )
+ {
+ overwriteMode ? overwriteText("\u2028") : insertText("\u2028");
+ }
else
splitParagraph();
event.preventDefault();
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/258787a7/textLayout/src/flashx/textLayout/elements/Configuration.as
----------------------------------------------------------------------
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 @@ package flashx.textLayout.elements
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 @@ package flashx.textLayout.elements
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
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/258787a7/textLayout/src/flashx/textLayout/elements/IConfiguration.as
----------------------------------------------------------------------
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 @@ package flashx.textLayout.elements
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.
*
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/258787a7/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
----------------------------------------------------------------------
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 @@ package flashx.textLayout.elements
{
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 @@ package flashx.textLayout.elements
{
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;