Creating layers of the multiline edittext fields multiline text questions

Hi all

I wrote a script that accepts a user input and puts in the part layerName.textItem.contents to a text layer, code example below.

var docRef = app.activeDocument;
var win = new Window("dialog", "Hello world");
var input = win.add("edittext", [0,0,400,40], "", {multiline:true, wantReturn:true});
input.active = true;
var go = win.add("button", undefined, "Go");

function makeText() {
     var myText = docRef.artLayers.add();
     myText.kind = LayerKind.TEXT;
     var ref = myText.textItem;
     ref.kind = TextType.POINTTEXT;
     ref.size = 50;
     ref.contents = input.text.replace(/\\n/g,'\r');
     win.close();
}
go.onClick = function() {
    docRef.suspendHistory("text", "makeText()");
}

win.show();

However, simply using entry for a new line in the input box produces unexpected results:

Screen Shot 2016-09-04 at 01.42.38.png

Curiously, the symbol of the copy and paste elsewhere show that it is a new line character, it is simply not recognized by Photoshop.

By setting wantReturn to false and adding a keypress eventListener:

win.addEventListener("keydown", function(kd) {pressed(kd)});
function pressed(k) {
    if (k.keyName == "Enter") {
        input.text += "\\n";
    }
}

I am able to get a new line correct, although each press of Enter brings the cursor at the beginning entry field, forcing the user to manually move the cursor at the end before you can continue typing. This too (of course, I guess) puts a visible "\n" in the input field.

Is there a solution that, at least, can prevent the cursor jumps at the beginning whenever you press Enter? Ideally the end user would not see "\n" in the input field at all, but rather a new visible line in the input field which translates a new visible line in the text layer.

I'm under CS6 on OSX but will mainly use the script from Windows, also CS6.

Thanks to all who can help.

Change line 13 for your regex to:

REF.contents = input.text.replace(/\n/g,'\r');

Tags: Photoshop

Similar Questions

  • Can someone help me with the properties of the multiline text field?

    Adobe is not my first or second language. I have been responsible for making a form to fill out and were able to understand a little after reading the Adobe Acrobat Bible, most, however, I just can't understand this little thing that's driving me crazy! I created a large default text field (so the person filling out the form to the management a little) this field is also defined as a multiline and also make field scroll long text. The problem is that the default text is highlighted not crept to crush then tab through the various areas of creation. He puts just the cursor at the end of the text by default so using back or manually select and delete text. I looked at how to set up the rest of the fields and the only thing different, I selected the multiline text box in the Properties menu. I need to be multiline text. If this is not the case, only the first words of the default paragraph I entered couple is visible. Any suggestions or ideas would be a step ahead of where I am now. Thanks in advance.

    Yesterday, we discussed a similar situation and the solution should work for you too: http://forums.adobe.com/thread/756410?tstart=0

    What you do is create a Format script that displays the text that you want, when the field is empty, but this text is not the value of the field. The modified script below prevents printing explanatory text if the field is empty.

  • The cursor position is centered vertically in the multiline text box

    When I insert a text field, resize the height so that it can accommodate several lines of text and select "Allow multiple lines", the cursor is always left-aligned, centered vertically in the text box when opened in Acrobat.

    Is there a way to force the cursor to appear in the upper left corner, enter text to display from the top of the text, rather than in the middle box?

    Hello

    You can set the alignment of the text (vertical and horizontal) in the font/palette tab.

    If you do not see in your workspace, you can select it from the Windows menu in designer LC or SHIFT + F5.

    Good luck

    Niall

    PS note that you can change the appearance of the legend and the value of the object, together or separately. This applies to the style of the police as well as paragraph settings.

  • Create focus on the custom edit field?

    There's my code to see the login screen...
    I want to create special border editfield when he onFocus? so people place now developed...

    public LoginScreen()
        {
            super( NO_VERTICAL_SCROLL | USE_ALL_HEIGHT | USE_ALL_WIDTH );
            this.getMainManager().setBackground(BackgroundFactory.createLinearGradientBackground(0x0099CCFF,
                    0x0099CCFF,0x009933FF,0x009933FF) );
    
            Bitmap logoEcc = Bitmap.getBitmapResource("ecc.png");           //call image
            BitmapField logo = new BitmapField(logoEcc,Field.FIELD_LEFT);               //make logo side left
            hfm = new HorizontalFieldManager(Field.USE_ALL_WIDTH)           //new horizontalmanager with All Width
            {
                protected void paint(Graphics graphics)
                {
                    graphics.setBackgroundColor(Color.BLACK);
                    graphics.clear();
                    super.paint(graphics);
                }
            };
            hfm.add(logo);
            add(hfm);
            add(new SeparatorField());
    
            username = new LabelField("Username", Field.FIELD_LEFT);
            add(username);
    
            usernameEdit = new EditField (Field.USE_ALL_WIDTH)
            {
                protected void paint(Graphics g)
                {
    
                XYEdges padding = new XYEdges(3, 3, 3, 3);
                int color = Color.BLACK;
                int lineStyle = Border.STYLE_SOLID;
                Border roundedBorder2 = BorderFactory.createRoundedBorder(padding, color, lineStyle);
                usernameEdit.setBorder(roundedBorder2);
            //  g.setBackgroundColor(Color.WHITESMOKE);
                g.clear();
                super.paint(g);
            }
            };
            add(usernameEdit);
    
            password = new LabelField("Password", Field.FIELD_LEFT);
            add(password);
    
            passwordEdit = new PasswordEditField ()
            {
                protected void paint(Graphics g)
                {
                    //g.setBackgroundColor(Color.WHITESMOKE);
                    g.clear();
                    super.paint(g);
                    XYEdges padding = new XYEdges(3, 3, 3, 3);
                    int color = Color.BLACK;
                    int lineStyle = Border.STYLE_SOLID;
                    Border roundedBorder2 = BorderFactory.createRoundedBorder(padding, color, lineStyle);
                    passwordEdit.setBorder(roundedBorder2);
                }
            };
            add(passwordEdit);
    
            add(new SeparatorField());
    
            login = new ButtonField("Login",Field.FIELD_HCENTER);
            login.setChangeListener(this);
            add(login);
    

    any solution? Thank you...

    Hello

    EditField ed = new EditField(){protected void drawFocus(Graphics f, boolean value)
    {              graphics.setColor(Color.BLUE);                 int width = getPreferredWidth();                 int height = getPreferredHeight();                 //Draw a border around the field.                 graphics.fillRect(0, 0, 3, height); //Left border                 graphics.fillRect(0, 0, width, 3); //Top border                 graphics.fillRect(width-3, 0, 3, height); //Right border                 graphics.fillRect(0, height-3, width, 3); //Bottom border
    
    }};
    
    
    

    Write like this...

  • Get the last value of a multiline text box

    Hello

    I have a form of acro with a TextBox multiline, a few radio buttons and text fields.

    When the user clicks on the radio button, the value of the multiline text box is displayed in another text box.

    This is the script for the option:


    The target field
    var t = this.getField ("programme of Action");

    Field value

    var g = this.getField("Agenda_Item").value;

    t.Valeur += g + "\n";

    What the script does, is show ALL values of the multiline "to the point" text box in the other text field 'Programme of Action '.

    I need the script to extract the last line or entry of the multi-line text box and put this value in the other field of text.  There could be any number of lines from one line to two, three, four lines etc.

    Can any advise please how the script can be modified to get the value of the last row in the multi-line text box?

    Any help will be most appreciated.

    You can split the string that is returned to carriage returns:

    var a = getField ("the order of the day Item").valueAsString.split(/\r/ ");

    You must then move backward from the end of the table until you meet an element of array not empty and use it.

    for (var i =. Length - 1; i >-1; i--) {}

    If (a [i]) break;

    }

    If (typeof a [i] = 'undefined') [i] = "";

    t.Valeur += [i] + "\r";

  • Why a form in InDesign CC 2014 multiline text field wraps not the text in the exported PDF file?

    I created a form in InDesign CC 2014. The form fields are text with a font size of 12 point and multiline text attribute. I export to PDF interactive form. Open the PDF file in Acrobat XI. When I type in the form field, the text is centered vertically in the form field and wraps around, when I type a value in addition to a line of words in the field.

    I would like that text to start at the top of the field and fill down. Also, I would automatically wrap it around the input text.

    Any advice?

    Delete any point in the name field.

    There is a problem like that if there is a point understanding between the words or numbers in the name of the text box in the button panel.

  • Extended CRM multiline text fields do not allow any line on the back-end breaks

    I added a multiline text field to a form of extended CRM and tie it to the Contact entity. When I login to the Admin and trying to change this field in the customer record, it does not line breaks. Pressing enter (or SHIFT-ENTER) while in the multi-line text box, saves the record. It takes me not to the next line in the text box, which is what I want.

    Hello

    At this stage in order to add a line break in a multiline text field, you will need to use either
    or
    to do so. Previously, it was possible to press on enter, but this feature has been removed awhile back months to increase safety, specifically related to possible vulnerabilities on cross site scripting.

    Kind regards

    -Sidney

  • How do you multiline text in a continuous form between the lines without scaling of the text?

    Help. How do you multiline text in a continuous form between the lines without scaling of the text?

    I tried to put each line of the form for amounts of specificity so that it ends at some point and does not change the text size to fit on the line but different key characters have different widths, so you do not get a length of the same line.

    I tried to remove the long text scrolling, but it changed nothing.

    I can create a text box great to fill out and have this scrolling of additional lines, but then I get too much information from people and I would need to clarify the lines behind the answer multi line text, or delete the lines...

    Is there a better solution?

    I usually just remove the lines and set the field "Does not scroll long text" so that all the text is visible. Including the lines is really only useful if the form may be printed and completed by hand, in which case you can use scripts as in this example is: http://acroscript.net/pdf/demos/multiLine_Demo1.pdf

    It works as expected in Acrobat/Reader, but not in Chrome and other PDF viewers who have little or no support for JavaScript. It uses scripts customized to validate on Focus and blur.

  • Multiline text field, not packing in PDF format

    Hello

    I work in InDesign CS6 and I have a text field where users can take notes at the bottom of each page on the master page. I have the right properties defined in the dialog buttons (see below). However, when a user enters text, the text is not wrapping (see image 2), it shows just as a long line of text. If I go to the PDF file and select the text box and choose multiline, it works, but I don't want to have to do this on each page of each document. Is there something I'm missing when creating the PDF file or set up initially in InDesign?

    Button properties.PNGNot scrolling.PNG

    The pages Panel, select all the pages containing a button text field then of flyout arrow select replace all elements of the master page. Hope this can help.

  • Masking printed lines in a multiline text field?

    I am designing a form using Adobe Acrobat XI. This form is designed to be multi use. It can be printed and completed by hand or it can be filled electronically.

    When the user chooses to complete the form electronically, entering into a multiline text field, I want to hide the printed lines. After leaving the field, I want the lines will still be hidden if any text has been entered in the field. I know that this can be accomplished by using a script in the Action of the box text field properties window, but I can't find the correct script and triggers. Any help is very appreciated.

    Here is the solution:

    In the onFocus event, you add this line of code:

    event.target.fillColor = color.white;

    and in the onBlur event, you add this line of code:

    If (event.value.toString () .length< 1)="">

    event.target.fillColor = color.transparent;

    }

    The script of the onBlur event is required to set back field transparent background when you tab through an empty field; When you tab through a field, the Format event will not occur.

  • Access of the edittext field name

    I created an edittext field and gave him the name "myText". That's what I tried.

    Window.Edit = Window.add('edittext', undefined,undefined, {name:"myText"});
    Window.Edit = func;
    
    function func()
    {
         alert(this.name);
    }
    
    

    However, I only get "undefined" as a result.

    How can I fix?

    I created an edittext field and gave him the name "myText". That's what I tried.

    Window.Edit = Window.add('edittext', undefined,undefined, {name:"myText"});
    Window.Edit = func;
    
    function func()
    {
         alert(this.name);
    }
    
    
    

    However, I only get "undefined" as a result.

    How can I fix?

    In fact, there are two problems in your code:

    First, restore you Window.Edit func, so Window.Edit is no longer being EditText do you think it is.

    Secundus, name is not a property of the construction EditText, so it is ignored at the time of construction of widget.

    However, you can add a building after the property name :

    var w = new Window('dialog', 'title');
    w.edit = w.add('edittext');
    
    w.edit.name = "myText";
    
    // useless, but it works:
    w.edit.getName = function(){alert(this.name);}
    
    // etc.
    

    @+

    Marc

  • VI Initialize with OptionsString missing the resource name field when creating the IVI Driver Generator LabView 8.6

    Hello world

    We have just uploaded the latest LabView version 8.6 and there is a nice tool called generator of LabView LabWindows CVI Instruments drivers. Our driver of the instrument is an IVI driver that has a LabWindows CVI interface that uses the generation of LabView tool to create all the VI that could be used to talk to the underlying driver IVI hollow discovery of .fp, .sub and .h files. No mistake and screws more than 30 are generated automatically.

    There is an inconsistency in the Initialize function IVI driver. There is a VI Initialize driver without an input of OptionString parameter and there is a second VI with the OptionString parameter.

    Two of these screws should have a required entry field that is the ResourceName of the instrument, but this field is visible in the initialization of VI that has no OptionString input parameter and is not at all visible in other VI initialize that has an OptionString input parameter

    No idea why the second version of Initialize does not display the ResourceName parameter?

    Thank you

    Sorin

    Hey Sorin and Heather,

    I've just built your IVI driver and can see the question you come through.  What version of LabVIEW and the tool are you using?  I am looking into this further for trying to dig your problem a little more.   If you add the connector to the connector pane, the created VI meets the needs that the name of the resource exists, it's just not in the connector pane.  This can do a right-click on the icon in the upper right of the front panel and selecting display connector.  Select where on the VI wish you add the connector, and then select the name of the resource.

  • [ADF, JDev12.1.3] SelectOneChoiche created from VO instance with 3 fields: how to retrieve the value of all the fields of the selected element?

    Hallo,

    I defined a VO with 3 fields (A, B and C) and I would like to create a SelectOneChoiche that shows only the field as options from this instance of VO.

    In a managed bean, I need to retrieve the values for all areas (A, B and C) of the item selected by the user.

    I started dragging the entire VO instance to UI to create a SelectOneChoiche (in which I have chosen to show only the to field).

    Then, I created a for the SOC ValueChangeListener read the values A, B and C of the selected element, but the only thing I've done is to get the displayed value:

    System.out.println((String) ((RichSelectOneChoice) FacesUtils.findComponent("MySoc")).getValue());
    

    You kindly help me?

    Thank you

    Federico

    Federico, sorry I didn't see your answer.

    As you use 12.1.3 you can do this more easily than the code that I posted before. You can use

    {} public void onCountrySelection (ValueChangeEvent valueChangeEvent)

    FacesContext will involve = FacesContext.getCurrentInstance ();

    Make sure that the selection change is processed and the current link lov line has the new selected line

    valueChangeEvent.getComponent () .processUpdates (contxt);

    BindingContext lBindingContext = BindingContext.getCurrent ();

    BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry ();

    List JUCtrlListBinding = lBindingContainer.get ("CountryId") (JUCtrlListBinding);

    the newindex in not necessary, but ok let's get it (must be equal to the CountryId, the pharmacokinetics of the binding of the lov

    String newindex = (String) valueChangeEvent.getNewValue ();

    get the selected value in the list that is the selected line of the binding of the lov

    Line lFromList = list.getSelectedValue () (line);

    now, we can get the attributes of the line of lov

    String s = (String) lFromList.getAttribute ("CountryId");

    System.out.println ("CountryId:" + s);

    String s2 = (String) lFromList.getAttribute ("CountryName");

    System.out.println ("CountryName:" + s2);

    BigDecimal s3 = lFromList.getAttribute("RegionId") (BigDecimal);

    System.out.println ("RegionId:" + s3.toString ());

    }

    The form that I use is based on the location of the HR DB schema table. The CountryId is configured in the view object to display a lov based on the campagneVoir. This view contains thre CountryId, CountryName and RegionId attributes.

    If you want to get to the attributes of an action listener you can use this code

    {} public void onGetSelectedCountryLov (ActionEvent actionEvent)

    BindingContext lBindingContext = BindingContext.getCurrent ();

    BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry ();

    List JUCtrlListBinding = lBindingContainer.get ("CountryId") (JUCtrlListBinding);

    get the selected value in the list that is the selected line of the binding of the lov

    Line lFromList = list.getSelectedValue () (line);

    now, we can get the attributes of the line of lov

    String s = (String) lFromList.getAttribute ("CountryId");

    System.out.println ("CountryId:" + s);

    String s2 = (String) lFromList.getAttribute ("CountryName");

    System.out.println ("CountryName:" + s2);

    BigDecimal s3 = lFromList.getAttribute("RegionId") (BigDecimal);

    System.out.println ("RegionId:" + s3.toString ());

    }

    You must add the valueChangeListener and at least add the lines

    FacesContext will involve = FacesContext.getCurrentInstance ();

    Make sure that the selection change is processed and the current link lov line has the new selected line

    valueChangeEvent.getComponent () .processUpdates (contxt);

    to ensure that the selected line is available when you click the button.

    And set autosubmit'= true for the field in the UI that displays the LOV.

    Timo

  • How long does it take for the custom field created in SFDC appears in the list of field mapping?

    How long does it take for the custom field created in SFDC appears in the list of field mapping? I hit the refresh field button, but it does not appear after 5 min. I just need to have patience?

    I had the same problem yesterday, I think it took about 10-15 minutes to appear.

  • I am creating a stamp of Certification of drawing dynamic shop with fields of text 'Name' and 'Date '. I tried different ways within Javascript, but I can't seem to make it work. The Date and time remains static on the stamp when it is inserted and

    I am creating a stamp of Certification of drawing dynamic shop with fields of text 'Name' and 'Date '. I tried different ways within Javascript, but I can't seem to make it work. The Date and time remains static on the stamp when inserted and always reflect when the stamp was created and the name is always my name. I try to have the user name or the username inserted so that he who is the insertion of the postmark of the stamp automatically inserts their name and what day and time the stap is inserted. I can't get this dynamic stamp works like the default Adobe Acrobat Dynamic stamps. Can anyone help with this one. Thank you

    Have you created a page template for your stamp? Did name the template of the page correctly? It's the right format:

    #InternalStampName = display name of stamp

Maybe you are looking for

  • MacBook Pro display problem

    Hello members of the community. As of recently, I have noticed some glitches when feeding on my MacBook or awakened from his sleep. The colors are distorted, usually with pink, green, or yellow blobs. Blobs cannot entirely replace the colors, they ap

  • Hide the list of accounts in the left in unified folders view window

    I am from Eudora and trying to put things up in a similar way on Thunderbird. To the extent where everything has been working PERFECTLY and I really didn't miss Eudora that much more. However, since I have several e-mail accounts (I participate in se

  • Internet connection lost because of the error of the Ethernet controller after installation of the OS

    OK, I installed Windows XP3 Pro on Windows XP2 Pro on my computer of friends because of severe virus problems. However after installation, the controller Ethernet, video card, etc. also took out drivers. The computer manufacturer is no longer availab

  • Partially responsive touchscreen Xperia Z2

    Hello world Yesterday my Xperia began to have what is called the question "ghost touch."Off the phone, nothing has been looking better. At this point, when I boot the phone, I can enter my PIN - sim, start the camera by the dedicated button and touch

  • Why Windows Media Player plays the song wrong when I click it in a playlist?

    I did a huge selection automatically (with 145 songs) with five-star is Windows Media Player 12 in Windows 7 on my Dell XPS L702X. So, let's say that I want to hear "Everybody Hurts [edit]" r.e.m. I click on n, it starts WMP play "Slips through my fi