6 Replies Latest reply on Sep 11, 2007 8:31 PM by wgb14

    Text processing

    wgb14 Level 1
      Hi all,

      I have two text-processing related questions that i wonder if you can help me with:

      1) How can i put a text chunk after the flashing cursor (or the Insertion point) in a field cast member using lingo? I have a numbe r of buttons with text lebbels and i want to allow my user to insert the text of the text labels after the Insertion point (which i can move it anywhere i want in my field member). Something like

      on mouseup

      textinsert = member("button1").text

      -- measure the amount of text before the flashing cursor

      -- put textinsert after the above amount of text

      end


      2) I am trying to bold a text chunk in my field cast member uising the below code, but it is not working. Any idea what I am doing wrong?

      on boldtext

      vMem = member("annotator")
      vSelect = vMem.selection
      if not(vSelect[1] = vSelect[2]) then
      chunk = vMem.char[vSelect[1] + 1..vSelect[2]]

      chunk.fontstyle = "bold"

      end if



        • 1. Re: Text processing
          Chunick Level 3
          when you get a selection you need to apply the formatting directly to the member... setting the text chunk to a variable creates a separate string in memory that does not reference the member's text anymore... so do this instead:

          on boldtext

          vMem = member("annotator")
          vSelect = vMem.selection
          if not(vSelect[1] = vSelect[2]) then
          vMem.char[vSelect[1] + 1..vSelect[2]].fontstyle = [#bold] -- use "bold" if it's a field member.
          end if

          ** Note: if you do want to set a variable then you can create a direct reference in memory using the undocumented .ref property, ie.
          textRef = vMem.char[vSelect[1] + 1..vSelect[2]].ref
          textRef.fontstyle = [#bold]

          -- this is useful when wanting to set several properties of a text chunk at one time.
          • 2. Re: Text processing
            McFazstp Level 1
            put textInsert after member( "annotator" ).char[( member( "annotator" ).selection )[2]]
            • 3. Text processing
              wgb14 Level 1
              Thank you both for your reply... My second question has been answered. As for the first I have something more that I would like some help. I wonder how can i change the color of the text in the textInsert variable and insert it with the specific color (e.g., red) in the member annotator.

              Many thanks for your help
              • 4. Re: Text processing
                McFazstp Level 1
                vMem = member( "annotator" )
                vInsertPos = ( vMem.selection )[2]
                put textInsert after vMem.char[vInsertPos]
                vMem.char[vInsertPos + 1..vInsertPos + textInsert.length].color = rgb( 255, 0, 0 )
                • 5. Re: Text processing
                  wgb14 Level 1
                  Thank you so much... just one more thing... although the text of the textInsert variable becomes red the problem is that if i will type a word after that text it is also red. Is there any way to make only the textInsert red and keep the rest of the text in the field black?
                  • 6. Re: Text processing
                    wgb14 Level 1
                    OK, I found a workaround to the above question by creating a menu items that will colorize the wanted text back to black. So topic closed many thanks for your help