【问题标题】:How to get the value of a slider in ApplescriptObjC?如何获取 ApplescriptObjC 中滑块的值?
【发布时间】:2014-11-03 23:23:28
【问题描述】:

property slider : missing value if slider's integerValue = 5 then -- Do something end if

此代码不起作用。任何想法为什么?

【问题讨论】:

  • integerValue() 返回一个可可类。如果您要在 Applescript 中进一步使用它们,您总是希望明确地将数字强制转换为 Applescript 类,以便在获取值时添加“作为整数”。

标签: applescript applescript-objc


【解决方案1】:

log class of slider's integerValue 返回一个叫做__NSCFNumber的东西

log class of 5 返回<NSAppleEventDescriptor: 'long'>

看起来 Applescript 不会自动为您转换值。为了让它工作(看起来很奇怪)转换会做到这一点:

if slider's integerValue as integer = 5 then
    -- Do something
end if

你好,迈克尔/汉堡

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-08
    • 2011-02-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多