【问题标题】:Support With Sharing AppleScriptObjC Variable To Label Object支持共享 AppleScriptObjC 变量以标记对象
【发布时间】:2015-09-12 12:52:19
【问题描述】:
   script AppDelegate  

        property theWindow : missing value
        property displayLabel : missing value

            on applicationWillFinishLaunching:aNotification

                    display dialog "Are you ready?" buttons {"Yes", "No"} default button "Yes"

            end applicationWillFinishLaunching:

            if result = {button returned:"No"} then

                display alert "That's a shame."

                tell application "This Application"
                    quit
                end tell

            else if result = {button returned:"Yes"} then

                set testVariable to "this is a test"

            end if

    end script

所以,这是我正在 AppleScriptObjC 中开发的应用程序示例。我已经取出了很多东西并用不同的字符串替换了东西,但这是基本布局。

如何将“testVariable”的值放入“displayLabel”属性中,该属性链接到界面构建器中的标签?标签最初是空的,但我希望在脚本运行后填充“testVariable”的值。

谢谢!!!

【问题讨论】:

    标签: xcode applescript applescript-objc


    【解决方案1】:

    语法与 ObjC 语法非常相似

    对象

    displayLabel.stringValue = testVariable;
    

    AppleScriptObjC

    set displayLabel's stringValue to testVariable
    

    【讨论】:

    • 感谢瓦迪安!这是一个很大的帮助。
    • 我想问一个后续问题,如果可以的话 vadian;在我展示的示例代码中,只要您打开应用程序,主应用程序窗口就会在对话框后面可见且为空白。有没有办法隐藏这个主应用程序窗口,直到选择了适当的对话框并填充了标签?谢谢!
    • 在 Interface Builder 中隐藏窗口(取消选择“启动时可见”)并使用 NSWindow 的方法 makeKeyAndOrderFront: 以编程方式显示窗口
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-30
    • 2014-07-12
    • 2015-05-29
    • 1970-01-01
    • 1970-01-01
    • 2014-10-13
    相关资源
    最近更新 更多