Set selected text as variable (CS3 with JS)

How can I set a piece of selected text as a string variable?
I'm running InDesign with InCopy CS3 on a Windows XP computer.

If you mean "assign the selected text to a variable", then you could do this:
var myText = app.selection[0].contents;
Peter

Similar Messages

  • A problem highlighting/selecting text in Illustrator CS3

    In several instances I can't highlight text to copy or to edit, other times it works fine. If I click the radio button for the text in layers (other layers may be locked to prevent accidental selection), the baselines appears and I should be able to highlight the text, but I can't. If I highlight some other unaffected area of text successfully (unlocked layers), sometimes it will allow me to select the problem text directly after. Then it will go back to being a problem, why?

    I'm using the general text tool, I've locked the other sublayers to avoid accidentally selecting those items. Then I click the radio button on the sublayer I wish to edit or copy, which reveals the baselines. Then if I click within that object to highlight text with the cursor, the text tool creates a new textbox/sublayer and does not highlight the text I intended.
    From: Monika Gause <[email protected]<mailto:[email protected]>>
    Reply-To: <[email protected]<mailto:[email protected]>>
    Date: Wed, 26 Oct 2011 14:49:40 -0600
    To: Roger Daleiden <[email protected]<mailto:[email protected]>>
    Subject: A problem highlighting/selecting text in Illustrator CS3
    Re: A problem highlighting/selecting text in Illustrator CS3
    created by Monika Gause<http://forums.adobe.com/people/Monika+Gause> in Illustrator - View the full discussion<http://forums.adobe.com/message/3992086#3992086

  • How to set selected text on JTextPane ?

    I need to set selected text on a JTextPane. I used setSelectionStart(); and setSelectionEnd(); but it doesn't work.
    Can anybody help me?

    I'm not sure if this is what you are looking for, but the following code sample was revised from the tutorial TextSamplerDemo.java. It will hightlight the word "selected" in yellow in the JTextPane.
    //created with j2sdk1.4.0_01
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;
    import java.awt.event.*;      
    public class SelectedText extends JFrame {
        public SelectedText() {
            super("Selected Text");       
            //Create a text pane.
            JTextPane textPane = createTextPane();
            JScrollPane paneScrollPane = new JScrollPane(textPane);
            paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            paneScrollPane.setPreferredSize(new Dimension(250, 155));
            paneScrollPane.setMinimumSize(new Dimension(10, 10));
            Container pane = getContentPane();
            pane.add(paneScrollPane);
        private JTextPane createTextPane() {
            JTextPane textPane = new JTextPane();
            String[] initString =
                    { "This is the ", //regular
                      "selected",     //selected
                      " text. "       //regular
            String[] initStyles = {"regular", "selected", "regular"};
            initStylesForTextPane(textPane);
            Document doc = textPane.getDocument();
            try {
                for (int i=0; i < initString.length; i++) {
                    doc.insertString(doc.getLength(), initString,
    textPane.getStyle(initStyles[i]));
    } catch (BadLocationException ble) {
    System.err.println("Couldn't insert initial text.");
    return textPane;
    protected void initStylesForTextPane(JTextPane textPane) {
    //Initialize some styles.
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    Style regular = textPane.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "SansSerif");
    Style s = textPane.addStyle("selected", regular);
    StyleConstants.setBackground(s, Color.YELLOW);
    public static void main(String[] args) {
    JFrame frame = new SelectedText();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    frame.pack();
    frame.setVisible(true);
    S.L.

  • JTextPane - setting selected text colour

    Ok, I have a bit of a problem. Here is some general information about my program.
    I have a JTextPane called "DDITextArea" and I can type in it and stuff. I want to be able to select some of the text and use a JColorChooser to set the text to that color of my choice. I am doing a bit of experimentation with the swing components and messed around with a JColorChooser. Here is the code for the chooser.
        ColourOption.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (first) {
              first = false;
              chooser.setPreviewPanel(new CustomPane());
            JDialog dialog = JColorChooser.createDialog(RecipeBrowser.this, "Demo 3", true, chooser, new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                    c = chooser.getColor();
                }, null);
            dialog.setVisible(true);
    *I NEED SOMETHING HERE TO SET THE SELECTED TEXT TO THE COLOUR I CHOOSE WITH THE JCOLOURCHOOSER
    *I HAVE A JTEXTPANE AND I WANT TO BE ABLE TO SELECT SOME TEXT THEN USE THE JCOLORCHOOSER TO SET THE COLOUR OF THE SELECTED TEXT
        });as you can see from the comments near the end of the code sample, I need to know how to set the selected text to Color c. I don't know if there is a method for this. I looked at the online Java syntax database but to no luck. Just to ensure that there is no misunderstanding I will give an example:
    DDITextArea has the sentence "The dog is wet and smelly" and its default font colour is black. If I highlight the words "The Dog", open the ColorChooser and select red, the words "The Dog" will be red while everything else is black.
    If it is any help, here is where my DDITextArea is created
              final JTextPane DDITextArea = new JTextPane();
              JScrollPane DDITextAreaScrollPane = new JScrollPane(DDITextArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
              //DDITextArea.setLineWrap(true);
              //DDITextArea.setWrapStyleWord(true);
              DDITextArea.setEnabled(true);
              DDITextArea.setEditable(true);
              DDITextArea.setVisible(true);
              gbc.fill = GridBagConstraints.BOTH;
              gbc.anchor = GridBagConstraints.CENTER;
              gbc.gridx = 1;
              gbc.gridy = GridY;
              gbc.gridwidth = 1;
              gbc.gridheight = 1;
              gbc.weightx = 1;
              gbc.weighty = 1;
              gbl.setConstraints(DDITextAreaScrollPane, gbc);
              PrintTab.add(DDITextAreaScrollPane);Am I missing any necessary syntax to do this or is there something much more complicated involved?

    Sorry for the double post but I figured it out. I missed the answer. This is a clear sign I must stop doing past-midnight research.
    Anyways, for any folds that have trouble with this in the future, here you go. I hope someone, somewhere, sometime, will have need for this.
        ColourOption.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (first) {
              first = false;
              chooser.setPreviewPanel(new CustomPane());
            JDialog dialog = JColorChooser.createDialog(RecipeBrowser.this, "Demo 3", true, chooser, new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                    c = chooser.getColor();
                }, null);
            dialog.setVisible(true);
    //THE CODE BELOW THIS COMMENT IS WHAT I ADDED
    new StyledEditorKit.ForegroundAction("", c).actionPerformed(null);
    //THE CODE ABOVE THIS COMMENT IS WHAT I ADDED
        });

  • SetCharacterAttributes sets selected text to p-implied tag

    I am trying to remove all font attributes from the selected text. I have used the setCharacterAttributes with the replace option set to true for both the TextPane and the EditorKit. The result is the selected text is changed to "<p-implied>". If I set the replace option to false the method works as advertised but this doesn't help me. I have not been able to find any such beast in previously asked questions. Any ideas?
    Steve

    If you still do not have solution try this :
    SimpleAttributeSet a = new SimpleAttributeSet(getInputAttributes());
    a.removeAttribute(CSS.Attribute.FONT);
    setCharacterAttributes(a, true);

  • 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

  • Can't set selected text in a JTextArea (bizarre)!

    I've go this method here to select text in a JTextArea is doesn't work.
    Any ideas?? I haven't posted ALL the code because there is quite a lot of it in a number of classes.
    public void selection(int i)
              String meth = methods.get(i).toString();
              String tex = tc.getText();
              int pos = tex.indexOf(meth);
              if (pos != -1) {
                   myTextComponent.setSelectionStart(pos);                myTextComponent.setSelectionEndpos+meth.length));                
         }

    Selected text is only shown when the text component has focus. Assuming you are clicking on a button to invoke your code you would need to reset focus on the text field:
    myTextComponent.requestFocus();

  • Marquee (horizontal scrolling) Text in Flash CS3 with AS2

    Hello,
    I know there is already some posts talking about marquee text, but none of them really answer my questions.
    First I'll explain my problem and what I'm trying to ahcieve. 
    Currently I'm trying to create a karaoke (the same kind of karaoke that you can find in the popular game: Rock Band) where the text is scrolling from right to left. For this I need to sustain a certain amount of speed if I want to stay in synch with the music, but what I noticed is when I'm going too fast the text begin to flicker and looks blurry, unless if I increase the FPS at 60, so the text begin to be clearer. But I need to make it run at 30 fps .
    More details:
    I'm trying to move my text at 350 pixels / seconds which give me a displacement of 11.6 pixels per frame when going at 30 Fps and when going at 60 fps it give me a displacement of 5.83 pixels per frame.
    What I've tried:
    - I've tried to apply an horizontal blur to my text to reduce in an attempt to reduce the flickering of the text but it didn't worked out.
    - I've tried to convert the text into graphic to see if I could get better results but it didn't help.
    My Questions :
    - Is there a suggested speed that we shouldn't go over if we want the text still be readable on screen while going at 30 Fps ?
    - Also I would like to better understand why it's look better at 60 Fps than 30 Fps.
    - Does anybody have any suggestions about my problem ?

    Thanks again Kglad,
    I really have no preference of Action Script since I don't have any significant experience with either one.
    I'll keep doing searches to see if I can get the information I need.
    Have a great holiday.

  • Problem with focus and selecting text in jtextfield

    I have problem with jtexfield. I know that solution will be very simple but I can't figure it out.
    This is simplified version of situation:
    I have a jframe, jtextfield and jbutton. User can put numbers (0-10000) separated with commas to textfield and save those numbers by pressing jbutton.
    When jbutton is pressed I have a validator which checks that jtextfield contains only numbers and commas. If validator sees that there are invalid characters, a messagebox is launched which tells to user whats wrong.
    Now comes the tricky part.
    When user presses ok from messagebox, jtextfield should select the character which validator said was invalid so that user can replace it by pressing a number or comma.
    I have the invalid character, but how can you get the focus to jtextfield and select only the character which was invalid?
    I tried requestFocus(), but it selected whole text in jtextfield and after that command I couldn't set selected text. I tried with commands setSelectionStart(int), setSelectionEnd(int) and select(int,int).
    Then I tried to use Caret and select text with that. It selected the character I wanted, but the focus wasn't really there because it didn't have keyFocus (or something like that).
    Is there a simple way of doing this?

    textField.requestFocusInWindow();
    textField.select(...);The above should work, although read the API on the select(...) method for the newer recommended approach on how to do selection.
    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",
    see http://homepage1.nifty.com/algafield/sscce.html,
    that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    Don't forget to use the "Code Formatting Tags",
    see http://forum.java.sun.com/help.jspa?sec=formatting,
    so the posted code retains its original formatting.

  • Selection texts are transported along report....

    hi friends i have a doubt regarding selection texts.
    i created selection texts for my report program . when i transport my report are this selection texts are transported along with my report or else do i need to do it explicitly.....

    Hi Chaitanya,
    When you transport you report, all the Text Elements i.e. Title and Headers, Selection Texts and Text Symbols also get transported along with your report.
    You need not do explicitly.
    Hope this helps.
    Please reward if useful.
    Thanks,
    Srinivasa

  • FDM Error - object variable or with block variable not set

    Hi all,
    When i try to configure the authentication provider in the fdm load balance manager, I've got an error "object variable or with block variable not set".
    version: 11.1.2.1
    If anybody can help me to resolve this. I will be thankful to him/her
    Waiting for replies.
    Regards,
    Edited by: Antoine on Aug 9, 2011 10:33 AM

    Try the following resolution
    The error "Object Variable or With Block Variable Not Set" is caused when the FDM Service account does not have "Write" share permission to the FDMDATA folder structure, which resulted in the FDM Service account being unable to write the text file that is produced when running a SQL Integration Script. Without being able to write to the directory, the import process cannot complete successfully. Could you please verify the following and update the SR accordingly.
    1) From the FDM Login screen select "Add Application" from the drop down list
    2) Login with a valid user
    3) Highlight the application that is experiencing the issue and click "modify"
    4) Locate the "Application Path", this is the location of the FDM Application Files. Connect to the server hosting the FDMDATA folder.
    5) Right-click on the FDMDATA folder and choose "Properties"
    6) Click on the "Sharing" tab and click the "Permissions" button
    7) Click "Add" and enter the id of the FDM Service Account used for all the FDM Configs and click OK
    8) Check the "Full Control" box and click "Apply"
    9) Click OK to save the changes.

  • Error in the Input scchduled.Object variable or with block varaible not set

    Hai Experts ,
    In the input schdueld , data is not accepting ..
    Its shows error : Object variable or with block varaible not set
    Please help..
    Regards
    Daya.........

    Hi SAP collegues,
    At my site, BPC Excel created this problem too "Object Variable or With Block Variable not set" .
    It turned out that this is symptom of a a dys-functioning BPC COM Plug-in in XL2007 or XL2010!
    This is a consequence that your Excel recently crashed while using BPC. And it relates to an Excel Add-in becoming disabled when the applications crashes.  Please check the following.
    Note before doing the following, close all other open Excel and BPC sessions.
    Within Excel go to File à Options
    Select the Add-Ins option on the left
    Select the <<COM Add-ins >> option in the Manage drop down, and click Go
    Make sure that the Planning and Consolidation option is selected.  If not, mark this box and click OK.
    If you do not see anything listed, return to the Add-in screen and select the Disabled Items option, and see if Planning and Consolidation is listed there.
    Let me know if you have any queries,
    Kind Regards,
    robert ten bosch

  • Find text from a file and set it as a variable in applescript?

    I am trying to build a script that sends me updates and notifications from cex.io. Please keep on reading below, so I may guide you until the point I have trouble with.
    The first simple script in this operation goes to cex.io's trading page for BTC/GHS. It records ands saves the text to a file every 4 seconds. It works great. It doesn't need to have safari refresh because the site pushes info to the browser live.
      repeat
              set the webpage_content to ""
              tell application "Safari" to set the webpage_content to the text of document 1
              set theText to webpage_content
              set a to "Macintosh HD:Users:PRIVATE:Desktop:CEX:"
              set theFile to (open for access file ((a) & "CEXRaw") with write permission)
              write theText to theFile
              close access theFile
              delay 4
      end repeat
    And it returns this from the site to this main file every 4 seconds: (note I cut off a chunk from the bottom and the top of the file, because they are unimportant)
        GHS:
        0.05233439
        BTC:
        0.00000223
        NMC:
        0.00002939
        LTC:
        0.00000000
        GHS/BTC
        0.02362958 LTC/BTC
        0.02438131 NMC/BTC
        0.00597565 GHS/NMC
        3.96951800 BF1/BTC
        1.67000000 Fund Account
        GHS/BTC
        Last price:
        0.02362958
        Daily change:
        -0.00018042
        Today's open:
        0.02381000
        24h volume:
        73812.35539255
    I now need an applescript to read that file, and return wanted values. But I'm lost on how to write it.
    It needs to find the number under BTC, and set it as a variable.
    It needs to find the number under GHS, and set it as a variable.
    It needs to find the number under Last Price, and set it as a variable.
    If anyone could script that really quick for me, or tell me how to do it, that would be amazing. Thank you so much!

    Couldn't tell if you had any whitespace in the lines (i.e. is there a space before or after GHS:), so I used contains, not is.  Also, if you have a line such as GHS/BTC with a colon GHS/BTC:  then it will also fail (as contains "BTC:" would be true for BTC: and GHS/BTC:)
    However, this will give you some guidance:
    set a to "Macintosh HD:Users:PRIVATE:Desktop:CEX:CEXRaw"
    set x to 0
    set Names to paragraphs of (read file a)
    repeat with nextLine in Names
              set x to x + 1
              if nextLine contains "BTC:" then
                        set BTC to item (x + 1) of Names
              else if nextLine contains "GHS:" then
                        set GHS to item (x + 1) of Names
              else if nextLine contains "Last Price:" then
                        set lastPrice to item (x + 1) of Names
              end if
    end repeat

  • Error: Object variable or With block variable not set.

    Hi,
    when i try to fill the control tables and browse for the target period in HFM (sys 9.3.1) i get the error: Error: Object variable or With block variable not set.
    When browsing for the target value in the location for the value no problem occurs.
    Anybody a clue?

    Hi SAP collegues,
    At my site, BPC Excel created this problem too "Object Variable or With Block Variable not set" .
    It turned out that this is symptom of a a dys-functioning BPC COM Plug-in in XL2007 or XL2010!
    This is a consequence that your Excel recently crashed while using BPC. And it relates to an Excel Add-in becoming disabled when the applications crashes.  Please check the following.
    Note before doing the following, close all other open Excel and BPC sessions.
    Within Excel go to File à Options
    Select the Add-Ins option on the left
    Select the <<COM Add-ins >> option in the Manage drop down, and click Go
    Make sure that the Planning and Consolidation option is selected.  If not, mark this box and click OK.
    If you do not see anything listed, return to the Add-in screen and select the Disabled Items option, and see if Planning and Consolidation is listed there.
    Let me know if you have any queries,
    Kind Regards,
    robert ten bosch

  • Error: Object variable or with variable not set while accessing

    Hi Friends,
    I am facing 'object variable or with variable not set' Error while opening BPC Excel.
    I have done, In Excel 2007, go to Excel Option -> Add-Ins -> Manage: COM Add-ins and Go...
    You look "BPC COM" disable and need enable again.
    But I am getting same Error message again and again. Please help me...
    I did BPC uninstall & install but still error massage poping
    Thank you in Advance

    Hi Kumar,
    I doubt if you are following the below steps. Please confirm. Thanks
    1. Open your normal Excel.
    2. Check for Planning and Consolidation tab on the top ribbon.
    3. I assume this wouldn't be available for you.
    4. If this is not present, open the Excel Options
    5. Click on Add-Ins and check the Active Application Add-ins
    6. Is Planning and consolidation present in it?
    7. If not, select "Disabled Add-ins" in the drop down below besides "Manage".
    8. Click "GO"
    9. Select the Planning and Consolidation add-in from disabled add-ins and "Enable" it.
    10. Check once again if this add-in is prersent in "Active" add-ins .
    11. Now close and re-open excel
    12. The Tab should be present now (Planning and Consolidation)
    Regards,
    Sanjeev

Maybe you are looking for

  • Macbook Pro 15 2.4 boot problem

    Hi I've recently replaced my keyboard after a coffee spill (quite straightforward) and it's been working fine ever since... However, since this morning, it has refused to boot properly.  I hangs at the apple logo screen for ages (20/30 minutes) and o

  • Ok, ANY information on HOW MUCH one other LICENSING costs for CS6-Premium & Web...

    I notice not on any of these posts is there any info about HOW MUCH it may cost for just one additional usage. (Please do not discuss or answer about I may be able to load on 2 'puters, this I already know) CAN ANYONE give an idea about one more usag

  • How to increase the screen resolution of oracle linux 4 in vmware?

    I have installed Oracle Linux Release 4 Update 8 for x86 (32 Bit) - DVD V16749-01 on vmaware for running oracle database 10g xe on my laptop. But its screen resolution is not greater than 800x600, (800x600 very small for my laptop which have 1366x768

  • Outbound trigerring for Inspection Lots

    Hi Friends, I am working on QM. I have to trigger inspection lots data in the form of an outbound idoc. I need to find out any creation/change in inspection lots data. In this scenario the inspection lots will be created/changed when: 1) there is a c

  • Several operation in one machine

    Dear All, my clile requirement is they have one machine they produce several things for example there is mixing machine where they mix chocolate, nuts, biscuits, etc many things in one machine with different capacity how can i map this scenario in sa