首页 > 解决方案 > 链接到转义键的对话框“取消”按钮

问题描述

我有一点 AS 打开一个对话框并提示用户输入,按钮选项为“取消”和“发送”(“发送”是默认按钮)。因为它是默认按钮,所以当我按下键盘上的回车键时,“发送”就会激活。当我按下键盘上的退出键时,我想激活“取消”。有没有办法将键盘键与按钮链接起来?我正在寻找一种编码解决方案,而不是应用程序设置解决方案,因为这块 AS 将由另一个应用程序运行。

任何帮助表示赞赏,示例代码如下!

set returnedThings to (display dialog ":message:" default answer "" with icon note buttons {"cancel", "send"} default button "send")
    set theMsg to text returned of the returnedThings
    set theBtn to button returned of returnedThings
    if theBtn is "send" and theMsg is not "" then
        -- do application specific tasks
    end if

标签: applescript

解决方案


Cancel如果大写,则自动链接到 ESC 键。


推荐阅读