flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vitali Kabak (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLEX-33278) Ctrl+V doesn't work properly
Date Thu, 18 Jul 2013 10:32:48 GMT

    [ https://issues.apache.org/jira/browse/FLEX-33278?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13712200#comment-13712200
] 

Vitali Kabak commented on FLEX-33278:
-------------------------------------

This problem is 100% reproducible in AIR application, but I couldn't reproduce it in browser.

1. Create and run a simple AIR application:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx"
			   >
	<s:TextInput maxChars="5"/>
</s:WindowedApplication>

2. Paste a text into TextField, using Ctrl+V. Text should contain a new line character, i.e.
"text_to
paste
for_bug"

 - copy text above without quotes.

3. Paste the same text again using Ctrl+V.
4. Now text field contains more characters then maxChar.

Same problem applies to s:TextArea.

Solution:

Fix "textContainerManager_flowOperationBeginHandler" method of spark.components.RichEditableText
at line 4706 (SDK 4.9.1) or 4713 (SDK 4.6.0)
Replace line:
  textToInsert = textToInsert.substr(0, maxChars - length1);
with line:
  textToInsert = textToInsert.substr(0, Math.min(0, maxChars - length1) );

String.substr(start:Number=0, len:Number=int.MAX_VALUE):String method has an undocumented
behavior: if len < 0, it will cut "-len" characters from the end of the string and not
return you an empty string, as expected.
So if new length of the text > maxChars, it still will insert non-empty textToInsert into
resulting string, so that it exceeds maxChar.

But I guess the real reason for this bug may lie somewhere inside TLF:
AIR app and browser app with the same code behave differently under debugger when inserting
the same text.
text.length returns 21 for browser and 22 for AIR (but it will change to 21 if you add "text"
variable to Expressions list in FlashBuilder and will stay 21 if you add "text.length" :(
)
It also seems that in AIR app TLF adds a new line character at the end of such inserted text
somewhere in the code.
                
> Ctrl+V doesn't work properly
> ----------------------------
>
>                 Key: FLEX-33278
>                 URL: https://issues.apache.org/jira/browse/FLEX-33278
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: Spark: RichEditableText
>    Affects Versions: Adobe Flex SDK Previous, Apache Flex 4.8 (parity release)
>         Environment: Windows 7
>            Reporter: Nazar Yavny
>
> The issue is present when user tries to paste text that starts with new line.
> When maxChars variable is specified and user tries to paste with Ctrl+V text bigger than
maxChars - component will cut of extra chars, but when user presses Ctrl+V one more time -
text will be pasted again. So, in this situation length of component's inner text will be
greater than specified maxChars variable.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message