function-key shortcuts for Styles?

Is it possible to assign a function-key shortcut to items in the Styles pull-down menu on the Ruler? I would, for example, like to be able to select text, press F1, and have the text turn red, or press F1, start typing, and have it be red.

I’ve a vague memory of something in the forums once, but have been unable to find a post.

With thanks for any help.

I don’t think that it’s possible to assign shortcuts to this menu but you might have a look at the scripts in the menu Scripts > Format > … You can assign shortcuts to them and a script to set the color of the selected text looks like this:

tell application id "com.devon-technologies.thinkpro2"
		tell selected text of think window 1 to set properties to {color:{65535, 0, 0}}
end tell

Thanks for the script :slight_smile:. It was in fact just those scripts (and their code) that inspired me to ask about the possibility of something even simpler. Two follow-ups, though:

(1) When you mention assigning shortcuts, do you mean via the three underline characters trick? Or was it some other method you had in mind?

(2) What exactly is the syntax for color specification in the script, with those three arguments? And I presume that number is simply the hex code?

That’s one possibility but does not yet support function keys (next beta will). Or use System preferences > Keyboard & Mouse.

Those are the decimal red-green-blue values ranging from 0 to 65535.

From comments I’d read elsewhere in the forums, I’d presumed that DT’s scripts weren’t available to System Preferences. But your confidence compelled me to go try it out, and it works, no problem! :smiley:. I post the fact for the sake of future browsers.

Even better: the Styles pull-down is in fact accessible via System Preferences as well. It’s available in both DT and TextEdit. I guess I should have checked the obvious before I made the first post :blush:

One qualification, however: although adding or deleting styles to the Styles menu in DT seems to be inherited in TextEdit (and vice-versa), the shortcut assignments aren’t. Keyboard shortcut assignments to shared styles, at least via System Preferences, seems to be application specific (which makes some sense).

OK. But I’m still don’t understand the three numbers in your script. I’m puzzled, because most of the formatting scripts on the internal script menu have those three numbers the same, whereas you’ve entered zeroes for the final two. Does that make any difference?

This sets red to 65535 (max) and green/blue to 0 (min).

I see. The other scripts have three identical numbers because they’re coding for gray. Thanks for the follow-up :slight_smile: .