【发布时间】:2019-06-16 21:59:00
【问题描述】:
感谢 red_menance 和 CJK,我编写了一些 ApplescriptObjc 代码。我做了一些更改,将其变成一个处理程序并弄清楚如何在 NStextview 中更改字体和字体大小,但是我在通过变量更改字体颜色和背景颜色时遇到了麻烦。
我正在尝试传递一个变量值,但看起来变量名被视为文字。那么如何让它接受变量值呢?这只是代码的 sn-p,如果有帮助,我可以发布整个脚本。
set theColor to "white"
set theBackgroundcolor to ""
if theColor is "" then
set its textColor to (current application's NSColor's whiteColor)
else
set theColor to (theColor & "Color") as string
set its textColor to (current application's NSColor's theColor)
end if
if theBackgroundcolor is "" then
set its backgroundColor to (current application's NSColor's grayColor)
else
set theBackgroundcolor to (theBackgroundcolor & "Color") as string
set its backgroundColor to (current application's NSColor's theBackgroundcolor)
end if
我得到的错误是: 无法将 «class ocid» id «data optr00000000E0F1320080600000» 的背景颜色设置为 NSColor 的背景颜色。 和 无法将 «class ocid» id «data optr00000000E029320080600000» 的 textColor 设置为 NSColor 的颜色。
【问题讨论】:
标签: appkit foundation applescript-objc