Skip to main content
Known Participant
June 18, 2008
Question

Applying None not removing Italics JS CS2

  • June 18, 2008
  • 4 replies
  • 969 views
Hello,

I hope someone can help me. I've got a little script going that does the
following. You place your cursor in any text. Run the script, and if the
text has an "Italics" character style applied, the script will apply
"[None]" instead to the entire run of text that has that style (like
textStyleRange, except that I'm not actually using that.)

The script works fine, and [None] char. style is duly applied to correct run
of text. However, the formatting IS NOT being removed. When I do this
through the UI (ie., manually select the text, and then click on None in the
char. style pallette), it does remove the formatting. The line of script I'm
using is:

mystory.insertionPoints.itemByRange(myStart, myEnd).texts[0].applyStyle
(mydoc.characterStyles.item ("[None]",true));

So even though I add the "true" parameter to the method, I'm not getting the
override I would like.

Please help if you can.

Thanks,
Ariel
This topic has been closed for replies.

4 replies

Jongware
Community Expert
Community Expert
June 19, 2008
Probably, because the applyCharacterStyle doesn't have an clearingOverrides parameter ...

Clearing the overrides for the entire paragraph is a bit overreacting. Try this text method instead:

>clearOverrides ([overridesToClear: OverrideType=ALL]);

-- the overridesToClear defaults to ALL, but you can specify PARAGRAPH_ONLY or (hey!) CHARACTER_ONLY.
Known Participant
June 19, 2008
I think I'll still go for Dave's suggestion. I do sometimes use local
formatting and, if I've understood correctly, your suggestion will strip all
local character formatting from the paragraph.

Thanks,
Ariel
Inspiring
June 18, 2008
Ah, Robin could well have put his finger on it. I always forget about ApplyStyle.

Dave
Known Participant
June 18, 2008
Phew, lightening speed answers; thank you so much.

Well, Robin definitely spotted a syntax error. But correcting it hasn't
helped. Whereas Dave's suggestion does work. IOW, applying a user-defined
character style does change the formatting, but not [None], even though
through the UI it does work.

Funny that.

Many thanks,
Ariel
Harbs.
Legend
June 18, 2008
Hi Ariel,

you can put in clearOverrides() after applying the style for the [None]
style...


Harbs
Known Participant
June 18, 2008
shouldn't be:

...("[None]"),true);

instead of:

...("[None]",true));

??

robin

--
www.adobescripts.com
Inspiring
June 18, 2008
What you have to do is make a new temp character style, apply it and then delete the style.

Dave