Control cursor in spark TextInput
Hi,
I am using flex 4.
I am using spark.components.TextInput control.
The valus of the text can be change dynamically according to user selection.
The problem is that after the user make action outside the textInput and change the value of the text the cursor position return to the begining of the textInput so if the user wants to continue enter .text in textInput he first need to move the cursor to the end.
How can I control the cursor position ?
Thanks
Save selectionActivePosition and selectionAnchorPosition, then call
selectRange
Similar Messages
-
Style Font in Spark TextInput Control
Hello!
How can I do as the title indicates please?
Can I do it without using a custom skin because I want to be able to change fontColor and fontStyle programatically.
Thanks!You can acheive it very easily with spark textinput too. Pls check below and let me know if you have any issue.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var acFontSizes : ArrayCollection = new ArrayCollection([
{fontSize : '12'},
{fontSize : '16'},
{fontSize : '20'},
{fontSize : '24'},
{fontSize : '28'},
{fontSize : '32'},
{fontSize : '36'},
{fontSize : '40'},
{fontSize : '44'}
]]>
</fx:Script>
<mx:VBox>
<s:TextInput id="txtInput" width="150" height="50" text="Your Text" fontSize="{comboFontSize.selectedItem.fontSize}" color="{colorCombo.selectedColor}"/>
<mx:HBox>
<s:Label text="Choose Color"/>
<mx:ColorPicker id="colorCombo"/>
</mx:HBox>
<mx:HBox>
<s:Label text="Choose Font Size"/>
<s:ComboBox id="comboFontSize" dataProvider="{acFontSizes}" labelField="fontSize" selectedIndex="0"/>
</mx:HBox>
</mx:VBox>
</s:Application>
with Regards,
Shardul singh Bartwal -
How to set selected text color in Spark TextInput
I'm trying to make Spark TextInputs and MXFTETextInputs look like Halo/MX TextInputs as much as possible, since I have a mix of both Spark and MX TextInputs in my application. I know I can set the
selection background color to black using focusedTextSelectionColor. How can I set the selected text color to white so it matches the MX white-on-black look?This works, if you set the enabled property directly on the s:TextInput:
<?xml version="1.0" encoding="utf-8"?>
<s:Application 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:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle" />
</s:layout>
<s:controlBarContent>
<s:CheckBox id="ch" label="enabled" selected="true" />
</s:controlBarContent>
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
s|TextInput:disabled {
color: red;
</fx:Style>
<s:Group>
<s:TextInput id="ti" text="The quick brown fox jumps over the lazy dog" enabled="{ch.selected}" />
</s:Group>
</s:Application>
It can get a bit trickier when you're setting the enabled property on a parent container, since (I believe) that the child control's enabled properties are still set to true and just the container is disabled. One possible workaround would be to bind the child TextInput control's enabled property to the container's enabled property. That way the s:TextInput should still go to it's disabled state and you can customize the disabled state's styles to have darker text, or whatever else you want.
<s:Group id="gr" enabled="{ch.selected}">
<s:TextInput id="ti" text="The quick brown fox jumps over the lazy dog" enabled="{gr.enabled}" />
</s:Group>
Peter -
Spark TextInput - prevent text highlight when tabbing in
How can I stop automatic text selection when I am tabbing into a Spark TextInput control?
ThanksWell, I still want to be able to highlight it with a mouse down. I want to turn automatic selection off when a user is tabbing into the control or it gets its focus programmatically.
-
Spark textinput does not display unicode properly
I need to type in some special charactors using unicode input method.
(install microsoft pinyin, and use secondary inputs-> unicode input, and type "E826" into the textinput box)
in spark textinput, the charactor is showing as a sqare; while mx textinput displays the charactor correctly.
does anybody know solution for this issue? or is it a known bug in flex? thanks!I did not set font for neither s:textinput nor mx:textinput. "Arial" should be used by default.
I am wondering how mx:textinput can work. is there any alternative font set for it by default?
I am not sure which font contains these special charactors.
thanks! -
Change text highlight colour in Spark TextInput
Hi,
As the title says, anyone know how to change the highlight colour in a Spark TextInput component? By the "highlight colour" I mean that if some of the text is selected this would be the background colour of the selected text.
Thanks.SetStyle("focusedTextSelectionColor", ...)
There are also unfocusedTextSelectionColor and inactiveTextSelectionColor
styles. -
In this example, the focus is set to the phoneInput object
but the cursor in this textinput is not set. How can I do this?
Thank you!
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="
http://www.adobe.com/2006/mxml"
viewSourceURL="src/FormatterSimple/index.html"
width="310" height="210"
initialize="focusManager.setFocus(phoneInput);"
>
<mx:PhoneFormatter id="phoneDisplay"
formatString="(###) ###-####"
/>
<!-- User interface -->
<mx:Panel
title="Using a formatter in an item renderer"
paddingLeft="10" paddingRight="10" paddingBottom="10"
paddingTop="10"
>
<mx:Text text="Enter a phone number,
including{'\r'}the area
code{'\r'}e.g., 2025558721:"/>
<mx:TextInput id="phoneInput" width="100%"/>
<!-- Display the formatted phone number -->
<mx:Text text="{'Formatted:
'+phoneDisplay.format(phoneInput.text)}"/>
</mx:Panel>
</mx:Application>I tried this and it doesn't work!
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="
http://www.adobe.com/2006/mxml"
viewSourceURL="src/FormatterSimple/index.html"
width="310" height="210"
creationComplete="focusManager.setFocus(phoneInput);"
>
<mx:PhoneFormatter id="phoneDisplay"
formatString="(###) ###-####"
/>
<!-- User interface -->
<mx:Panel
title="Using a formatter in an item renderer"
paddingLeft="10" paddingRight="10" paddingBottom="10"
paddingTop="10"
>
<mx:Text text="Enter a phone number,
including{'\r'}the area
code{'\r'}e.g., 2025558721:"/>
<mx:TextInput id="phoneInput" width="100%"/>
<!-- Display the formatted phone number -->
<mx:Text text="{'Formatted:
'+phoneDisplay.format(phoneInput.text)}"/>
</mx:Panel>
</mx:Application> -
i have a spark textinput, this textinput is stuck and wont disappear when popping or pushing to a new view any idea ? also sometime this textinput and when scrolling is stuck in a certain x-y position and do not move with scroll
below is my code:
<s:BorderContainer borderVisible="false" backgroundImage="@Embed(source='../assets/BGNotifications.jpg')" backgroundImageFillMode="scale" width="100%" height="100%">
<s:Scroller id="homeScroller" y="0" pageScrollingEnabled="false" name="homeScroller" height="100%" width="100%" horizontalScrollPolicy="off" verticalScrollPolicy="on" skinClass="Skins.HMobileScrollbar" >
<s:VGroup width="100%" horizontalAlign="center" verticalAlign="top" gap="0">
<s:VGroup horizontalAlign="center" paddingTop="45" paddingLeft="10" width="85%" height="100%" verticalAlign="top" gap="0">
<s:TextInput id="txtUsername" width="{278 * txtRatio}" height="{40 * txtRatio}" borderVisible="false" color="#575757" focusColor="#C42828" textAlign="left" fontStyle="normal" maxChars="200" styleName="{MystyleAccordingToWidth}TextBox{resourceManager.getString('resources','ImageP ath')}" ></s:TextInput>
</s:VGroup>
</s:VGroup>
</s:Scroller>
</s:BorderContainer>Hi, it sounds like you are running into a known issue with a mobile app using the spark textinput (assuming its mobile as you are referring to piping and pushing views)
The kind folks over at Flexicious have provided a solution to this problem
http://blog.flexicious.com/post/Scrolling-Issues-With-TextInput-for-Flex-Air-Mobile-Native -StageText.aspx -
Spark TextInput does not bring up soft keyboard in iOS?
I created an app with TextInputs that was working fine, bringing up the soft keyboard in both Android and iOS devices. After being away from it a couple weeks, when I made some unrelated changes, it no longer brings up the keyboard at all on iOS, and on Android it no longer displays the contents of the TextInput while typing, with the "Done" button.
I can't think of any changes I made that would cause this change...
I found old posts here and elsewhere about the Spark TextInput not triggering the v keyboard, but they're all a year old, and I know I've been fine until now.
Can anyone help?
Thanks!I was able to get it to work again by no longer using an mxml skin, which I was using to make the corners square, not rounded. Once I removed the skin reference, it brought up the keyboard again. Do you know why this might be? And could you tell me why there are forum exchanges around saying spark textinput cannot bring up the keyboard, only the mx:TextInput can? Perhaps they date back to an early beta version of the sdk?
Thanks!
Jack -
Transport Controls / Cursor
This might be a bit basic - but it's another thing I am sure is "in there somewhere" ... but I can't find it!
Is there a way of continuing playback from where you stop?
Currently, if I listen back to a section of programme (say from the beginning), then press <space> to stop it (having listened to, say, 10 mins of programme) ... when I press <space> again, it goes back to where I started from originally. Frustrating!
I am sure this is a simple one - there must be an option somewhere to continue play from where it last stopped...?
Oh, mysterious Adobe experts, help me again! (I promise I'll stop asking daft questions, then...)stevedoherty wrote:
Is there a way of continuing playback from where you stop?
Generally, one uses the 'pause' control...
Okay, as it stands that's not too convenient, but there's an easy way to fix this if you have a numeric keypad with the large '0' at the bottom.
Go to Edit>Keyboard shortcuts and MIDI Triggers, and scroll down the list until you get to Transport Play All/Pause toggle, and highlight it. Now put the cursor in 'Press for new shortcut key' and hit the 0/insert key on the numeric keypad. The box should now say 'insert', and there shouldn't be any conflicting keys unless you've assigned this to something else. And that would probably have been a mistake, because this is more useful. Anyway, click Okay and you're done.
Now for normal play you can use the spacebar, but for play/pause you can use the insert key. Pretty easy when you get used to it...
Oh, mysterious Adobe experts, help me again! (I promise I'll stop asking daft questions, then...)
I just get this feeling that somehow, this isn't going to happen yet. And why are we such a mystery? This bloody forum's more of a mystery than we are! -
Table Control - Cursor placed on same field
Hi,
I am facing one problem in a User defined Screen that having Table control.
I written some validations for each and every field in Screen including Table control.
But each & every time i am pressing Enter , the cursor is going to first field in the screen . I want to restrict this one...i want to be cursor on the field which i entered value at that time or next navigation field.
How i can achieve this...cursor should stay on the same field , it should not go to first field.
Pls give ur suggestions...
Thanks in Advance,
Best Regards,
pavan.Hello Pavan,
This is the first time I'm coming across this problem and I find it quite peculiar. Anyways, I can think of one option that you can try out.
Use the option GET CURSOR FIELD to get the cursor in the PAI event and then use the SET CURSOR FIELD statement in the PBO to set the cursor to the appropriate field.
Regards,
Anand Mandalika. -
Controling cursor position.........
AOA
how could i control the cursor position on my swing GUI.
Suppose i have two JTextFields jt1 and jt2.
jt1 lies above jt2 in jPanel. My requirement is to have cursor in jt2 instead of jt1 at start of GUI application.
How could i contrl curosr position.
RegardsJTextField inherits the grabFocus() method from JComponent, try using that.
-
How can I set cursor position inside TextInput or TextArea
Hallo.. I can't find the way for changing che cursor position inside a String in the TextInput or TextArea Component.. I hope you can help me..
Thx
MaxsetSelection(index, index);
-
I am creating a custom TextInput item renderer:
package
import spark.components.Grid;
import spark.components.TextInput;
import spark.components.gridClasses.GridColumn;
import spark.components.gridClasses.IGridItemRenderer;
public class gridTextInput extends TextInput implements IGridItemRenderer
public function gridTextInput()
super();
setStyle("borderVisible", false);
When I run my code the renderer still has a border. What's wrong with my code?
ThanksWorks for me. Do you mean the grid lines? or the actual border of the TextInput? What happens if you set borderVisible to true?
A workaround would be to reskin the TextInput and remove the border.
-Kevin -
Embedding .ttf font in Spark TextInput "prompt"?
This is what i have:
Main.mxml:
<fx:Style source="Main.css"/>
<s:TextInput x="72" y="95" focusColor="#CECB02" prompt="E-mail: "
skinClass="components.TextInputSkin"/>
TextInputSkin.mxml:
<s:RichText id="promptDisplay" includeIn="disabledWithPrompt,normalWithPrompt" x="10" y="7"
color="#666666" fontFamily="Acens" fontSize="15" trackingRight="1"
color.normalWithPrompt="#333333"/>
<s:RichEditableText id="textDisplay" d:userLabel="Text Display" x="10" y="7" width="230"
fontFamily="Acens" fontSize="15" heightInLines="1"
width.normal="282" color.normal="#999999"
tabStops.normal="S0 S50 S100 S150 S200" trackingRight.normal="1"/>
Main.css
@font-face
fontFamily: Acens;
src: url("C:\WINDOWS\Fonts\Acens.ttf");
embedAsCFF: true;
So, the "promptDisplay" in a computer(online) that does not have "Acens.ttf" installed shows the predefined one, but the inputed text is showed correctly with the embeded font!! Any explanation/solution for that!?
Thanks ;-)Thanks for the reply
It's predefined in "italic" and this font doesn't have it.
But if it's like you are saying, why do i see it in my computer (even if the file it's in a server) with the font i choose and in "italic"!?
Thanks again ;-)
EDIT:
Ok.. so i change the prompt fontStyle to "normal" and it works in every computer. ;-)
But it's strange that in the local computer it does the transformation to italic when i want!! :S
Thanks again ;-) problem "solved"
Maybe you are looking for
-
Spool list not available from SM37
Hi All, We have scheduled a job and running successfully. But spool list not displayed from SM37, whereas spool request generated in SP01 at the same time when the job is completed. We've checked with the developer and they dint find anything wrong f
-
How to manually edit a "Table of Contents"
How do I set a table of contents to display "..." or align in a "nicer way" - either through manual editing or some advanced automatic vodoo. Right now my TOC looks like this: Uploaded with plasq's Skitch! And that's not a good thing.
-
Hi, I was trying out a requirement in BPEL. I need to create a correlation set with a value that I generate within the process . I see that, when u define the correlation(property alias) it is mandatorily related to a message type and the Xpath point
-
Here we go, 1) at login a black rectangular box with white text appears and voice over seems to be on (even though its switched off) 2) after login an annoying black square surrounds the cursor 3) upon waking computer from sleep the bluetooth doesn't
-
How can I get access in Imatch to my own songs, several thousand, which I imported over the years. Also, when I try to re-import cds, Preferences, Import only works sporadically. Mainly, I want Itunes to repost the songs I imported from cds. Thanks.