如何使用 AppleScript 更改按钮的颜色文本?

How to change color text of Button with AppleScript?

有没有办法在选择按钮时更改按钮文本的颜色?

我试过类似的方法:

property myButton : missing value

myButton's setTintColor:(current application's NSColor's cyanColor)

但是我得到以下错误:

-[NSButton setTintColor:]: 无法识别的选择器发送到实例 0x7fc865f2d000(错误 -10000)

要将颜色等属性应用于按钮标题,您可以使用 NSAttributedString,例如:

    set buttonTitle to myButton's title -- get current title
    set attrString to current application's NSMutableAttributedString's alloc's initWithString:buttonTitle
    attrString's addAttribute:(current application's NSForegroundColorAttributeName) value:(current application's NSColor's cyanColor) range:{0, buttonTitle's |length|}
    set myButton's attributedTitle to attrString