Skip to main content
Participant
January 29, 2025
Answered

Hyphenation Settings slider

  • January 29, 2025
  • 1 reply
  • 565 views

Hi,

 

I've created a simple script that will apply some Hyphenation and Justification Settings but I'm having trouble accessing that slider from Hyphenation Settings. Does anyone know how to set a value for it?

Thanks in advance.

 

Correct answer Joel Cherney

You're looking for "hyphenWeight".

 

I can't tell you exactly how you can use it without knowing more about what you're trying to do. But, for example, imagine you had dozens of paragraph styles to edit, and you didn't want to have to click around manually like some pixel-stained technopeasant wretch. You might want to write a script to e.g. step through all your paragraph styles and slam the slider to "Better Spacing" in all of 'em. You'd want to loop through all paragraph styles, except that I assume you wouldn't want to touch paragraph style 0 (that's "No Paragraph Style") and paragraph style 1 (that's "[Basic Paragraph Style]").

 

So your script would look like this:

for (i=2; i < document.allParagraphStyles.length; i++) {
  document.allParagraphStyles[i].hyphenWeight = 0
}

 

If you wanted the slider at the other end ("Fewer Hyphens") then you'd want to set hyphenWeight to 10.

 

You can find hyphenWeight in a lot of places besides allParagraphStyles; I'd suggest that you search someplace like indesignjs.de/extendscriptAPI/indesign-latest/, and see which object(s) are most applicable to your situation. 

1 reply

Willi Adelberger
Community Expert
Community Expert
January 29, 2025

It is part of the paragraph styles? Why scripting? Adust and work with paragraph sryles. 

Participant
January 29, 2025

Thanks. I know it's part of the paragraph styles but for my purpose I need to access that via scripting.

Joel Cherney
Community Expert
Joel CherneyCommunity ExpertCorrect answer
Community Expert
January 29, 2025

You're looking for "hyphenWeight".

 

I can't tell you exactly how you can use it without knowing more about what you're trying to do. But, for example, imagine you had dozens of paragraph styles to edit, and you didn't want to have to click around manually like some pixel-stained technopeasant wretch. You might want to write a script to e.g. step through all your paragraph styles and slam the slider to "Better Spacing" in all of 'em. You'd want to loop through all paragraph styles, except that I assume you wouldn't want to touch paragraph style 0 (that's "No Paragraph Style") and paragraph style 1 (that's "[Basic Paragraph Style]").

 

So your script would look like this:

for (i=2; i < document.allParagraphStyles.length; i++) {
  document.allParagraphStyles[i].hyphenWeight = 0
}

 

If you wanted the slider at the other end ("Fewer Hyphens") then you'd want to set hyphenWeight to 10.

 

You can find hyphenWeight in a lot of places besides allParagraphStyles; I'd suggest that you search someplace like indesignjs.de/extendscriptAPI/indesign-latest/, and see which object(s) are most applicable to your situation.