TextField input not working - actionscript-3

I am working on a class similar to the standard text field. I actually use the default TextField inside it. My only problem is that the textField does not work correctly. If I set it to textField.type = TextFieldType.INPUT, I can delete the text, but I can't enter new text. Also, the cursor is not being displayed. This is my Class (part of it): http://pastebin.com/LsgQjxpa
The skin is like this: http://pastebin.com/yDhEGHLm
I can't figure out what exactly I am doing wrong. I also have to mention that I am compiling for AIR Mobile and testing directly from Flash Builder

One problem appears to be that you have set the selectable property to false. This makes sense when type is TextFieldType.DYNAMIC. However, it's problematic when the type is TextFieldType.INPUT.
When you disable selection of the text, no cursor is displayed. I am able to still edit the text. However, since the cursor is not visible I cannot change it's position and the text gets added in front of any existing text.

Related

Text not appearing on textfield

To appear softkeyboard for android app i written textfield.needsSoftKeyboard = true and onclick on textfield call textfield.requestSoftKeyboard() method. keyboard is appearing..but the problem is text is not appearing on textfield...
It would make sense if you could post the code snippet here for further investigation. Other than that, it might be that your textfield loses focus for some reason so you may get your issue resolved by calling "stage.focus = textfield;". It could also be the case that there is a problem with font embedding or styles (e.g. white text on white background). Make sure the textfield shows text at all by passing a prefilled text to it. There is currently also a bug, where Chinese and Japanese chars cannot be displayed on some Android devices (https://bugbase.adobe.com/index.cfm?event=bug&id=3839647).
Problem is textfield loses focus.Finally I got solution.We have to set Focus for that tlf textfield like this.txtField.textFlow.interactionManager = new EditManager();
txtField.textFlow.interactionManager.selectRange(0, 0);
txtField.textFlow.interactionManager.setFocus();

FLEX: HTMLText paragraph tag adding extra line break

Alright, So I have an issue that is a bit weird. I am using a RichTextEditor and have allowed the user to re-size it. All the controls have been stripped away to a main toolbar such that the RichTextEditor just looks like a box with text in it. I have an issue where when I save the htmltext generated by the editor and then re-render it later it always adds an extra line break at the end of the text. I've found that this is due to the paragraph tag, and since I want the user to be able to align text I have to keep it. Does anyone know how to strip this last line break without stripping all the formatting?
I hacked a fix for this, basically involves stripping the last closing paragraph tag </P>. RichTextEditor is ugly :(
This is absolutely a bug, and it is triggered by setting the "htmlText" property instead of the "text" property. This occurs whether you assign it in code, or cause the designer to set "htmlText" instead of "text" by checking the "render as html" button in the properties for the text field. Also of note, this only occurs on "input" type TextFields. And if you start with a "dynamic" type textfield and subsequently set "type" to "input" (also have to set "selectable" to true or cursor will be invisible (another bug)), you will see the extra line appear right in front of your eyes. Again, this does not effect dynamic text fields, just those in input mode.
Despite the fact that the htmlText property is identical in both cases whether you assign a string like "Hello" to text or htmlText (the htmlText value generated is identical for either), the extra line only appears when setting the htmlText property.
Specifically, it occurs when you set htmlText to a string that actually contains html paragraph tags. If you just assign htmlText some text like "Hello", the problem will not occur. On the other hand, if you assigned htmlText <p>Hello</p> or you assigned htmlText to itself (which you need to do to preserve the html and force the internal metrics to update immediately), then the problem occurs. Someone mentioned, if you omit the closing </p> tag, the problem won't occur, and that's true. It's also true that assigning something like <a>Hello</a> won't trigger the problem.
So in summary, this problem occurs only when one sets the htmlText property of an auto-sized, multiline, input type text field to a value that contains <p></p> tags. It does not occur with dynamic text fields, nor does it occur on input text fields that are not autosized, nor does it occur on those who are autosized but not assigned <p> tags to htmlText.
To reproduce this problem, set up a text field in the designer and make sure the background and outline is turned on so you can see the size of the field, then it will be a single line high (multiline text field) as expected (assuming it's wide enough). If you then go to the code and set txtfld.htmlText = txtfld.htmlText (set it to itself), this mere assignment of htmlText property (to it's own same value) causes an additional line to be added. And the value of htmlText is in fact the same, it hasn't actually snuck in an extra <p> tag or anything... it just displays this trailing return that shouldn't be there. As expected, the same thing occurs when you check "render as html" in Flash properties for the text field, which seems to cause it to set htmlText instead of text, and causes the problem to appear.
It's unlikely that there are actually two rendering modes, since it technically always renders htmlText (i.e. htmlText always has a value, and you could always set the text format of some segment of the text with setTextFormat, which was originally assigned with "text", and that doesn't trigger some kind of switch to "html rendering mode" or anything like that.
The behavior seems to strictly come as a result of assigning htmlText property.
The only way to avoid it (aside from setting htmlText, reading back the value, stripping the last </p> tag off, and reassigning it), is to just initialize all your text fields as plain "text", and then manually apply the formatting through calls to setTextFormat( TextFormat, beginIndex, endIndex).
The true catastophe of this bug, as mentioned in the original problem post, is that you cannot save and restore the htmlText value of a TextField, because setting htmlText to a string containing html (specifically the p tag), causes this extra line to be added, compounded by the fact that if you specifically want the textfield to be sized right, you'll probably have autosize turned on, and that's specifically when this problem creeps up and ensures the size is NOT right.
I had a similar headache with flex html text components. Flex does not have proper support for many html cases. You'll see extra padding for <p> and <li> all the time. Heck, there isn't even support for the <ul> tag. If there is a line break in a normal text, flex appends extra padding at the end of the tags and removing this line break will remove the extra padding.
However, you might want to use something like this: http://code.google.com/p/flex-htmlfilter/

How to Change Text Cursor Color of Text Input Flex 4?

I want to change the blinking text cursor color of Text Input in Flex 4...
How can I change it ?
Is there any way to handle it, or it can be only controlled by Flash Player ???
I had a similar question about this a while ago. I never found a way to update the actual cursor, so I got creative with the solution. My solution was to have two textfields stacked. One input field on top of a dynamic field.
Set the alpha of the input field to 0. Then, add a CHANGE event listener to the input field. In the handler, update the dynamic field and reposition your cursor based on the textWidth.
Not ideal, but it did the job.
I had solved this problem,
Actually there was a problem in skinning of text input.
If we set textinput skin's richeditabletext's alpha to 75 or some down value, flash player makes cursor color white itself.
So by increasing that alpha value, I got the cursor color black.
I change the TextField.textColor = OxFFFFFF, the cursor changes into white as well. Works for my case when I need the same color for the blinking cursor and text.

ActionScript Setting Caret Position In Text Layout Framework

i'm attempting to simply set the caret position at the start of the text flow when it is first displayed, without having to click and activate the text to see the blinking caret.
googling returns that the solution is to do this:
textFlow.interactionManager = new EditManager(new UndoManager());
textFlow.interactionManager.setSelection(0, 0);
however, setSelection() is not a valid function of the selection or edit managers.
1061: Call to a possibly undefined
method setSelection through a
reference with static type
flashx.textLayout.edit:ISelectionManager.
figured it out. for anyone else who ever has to deal with the nightmare that is the text layout framework documentation, you can automatically position and display the blinking caret after the text is displayed by writing this:
textFlow.interactionManager.selectRange(0, 0);
textFlow.interactionManager.setFocus();

AS3 AutoSize Textfield

in AS3, I'm making this dynamic textfield that is populated from an XML file based on where the user clicks.
The dynamic textfield has a custom scrollbar to it. My problem is that if the text inserted into the textfield is less than the previously displayed text, you can still scroll the dynamic textfield as far as the previous one.
Is there a way to reset the textfield autoSize?
Many thanks,
If you are talking about Flash ( I have very little experience in Flex ) then the textField.autosize property would probably get you in the right direction.
I think this link will tell you exactly what to do.
Are you using any of the standard flex controls? Or, is this flash?
You can set the width of the field to the string length + some space (by binding the width to the string's length/event handling etc). This may be of interest. Of course,
Try this, wrap the xml elements text in
<text><![CDATA[<span class="someClass">Some Text Here</span>]]></text>
If the prior wasn't wrapped in CDATA, flash would have taken the <span class="someClass"> and attempted to drop it down a line and indent it as you would with XML hierarchy; CDATA tells flash to ignore those characters and literally treat them as a string. The result of not using this process is that there are many odd spacings in your textfield.
Also be sure that your TextField is set to Multiline and wordwrap, as well as autoSize such as TextFieldAutoSize.LEFT;