Page 1 of 1

Text format

Posted: Wed Apr 10, 2013 4:21 pm
by Rod Edwardson
Hello

I have an issue that has me stumped. I have a button that clears some text formatting in a text field. For some reason the result provides me with underlines text in the first (Field s) text field. I have tried setting the the textstyle to plain with still no result. Any ideas?

Code: Select all

on mouseUp
   if the environment = "development" then touchEnd 1
      select the text of field "Field s" 
   set the textColor of the selectedText to black
   set the backgroundcolor of selectedText to white
   put "" into Field "fldNotes"
   select the text of field "fldHidden"
  end mouseUp

Re: Text format

Posted: Wed Apr 10, 2013 5:32 pm
by jmburnod
Hi Rod,
I tried your script directly and i was surprised it work without error
(except the second line of course).
About your script:
textColor and backgroundcolor are only for controls not for selectedText
It works not how expected but with a strange behavior. Congratulation you created something new. :D

I put a little stack in attachment like you described
1. A blue "points underline" as you said on the selected text for the first
2. An expected behavior for the second
I have no explanation. Does anyone have one ?
Best regards
Jean-Marc

Re: Text format

Posted: Wed Apr 10, 2013 5:35 pm
by jacque
Your script should work if you use "the selectedchunk" instead of "the selectedtext".

Re: Text format

Posted: Wed Apr 10, 2013 5:47 pm
by jmburnod
Rod,
Sorry, I'm wrong
textColor and backgroundcolor are only for controls not for selectedText
selectedChunk is probably what you want but i don't understand the goal

Jacque,
I never seen this fld behavior

Best regards
Jean-Marc

Re: Text format

Posted: Wed Apr 10, 2013 11:50 pm
by Rod Edwardson
Hello

selectedChunk does not seem to work either. To confuse things further, I have another stack that uses the same script and it works fine. Anyway, not the best way to handle it I'm sure but I have come up with a fix for my goal. I have a string of text that is stored in a variable. When my stack loads, that text gets placed into the text box. I have an option menu that searches the text box for different words and formats the result with different colour text. In the clear formatting button, where the script in question resides, I have amended it just closed the stack and re-opened it again. When it re-opens, the initial text from the variable gets put back into the field, nicely formatted as I want it. Works but not ideal. And I am not sure why its working on the other stack? Oh well, thanks to all for their ideas!

Rod

Re: Text format

Posted: Thu Apr 11, 2013 12:26 am
by asayd
Rod,
I'm not exactly sure what you are trying to do, but if you just want to clear all formatting from the text in the field try something like this:

Code: Select all

set the textStyle of char 1 to -1 of field "myFld" to empty
If you just set the textStyle of the field, the properties that have been previously set on any chunk of text in the field will retain those properties. Think of text inside a field as a child of the field that can have its own properties.

Hope this helps.
Devin

Re: Text format

Posted: Thu Apr 11, 2013 1:27 am
by dunbarx
What Asayd said.

And his description of the situation is spot-on. I frequently trip up on this, carelessly setting field style properties where the field already contains styled text within it, and expecting the text itself to follow suit.

Craig Newman