美文网首页
AppleScript-dialog 弹出框

AppleScript-dialog 弹出框

作者: 不写昵称 | 来源:发表于2018-07-29 18:14 被阅读0次

    普通弹出框

    形式:display dialog 标题名 buttons 按钮标题列表 default button 按钮或序号
    点击按钮后,返回值是record类型,格式如:{"button returned":"xxxx"}
    获取返回值 :get the result
    获取返回值中的字符串:the button returned of the result
    弹出框会阻塞程序运行,可根据返回值决定下一步操作

    举例:

    set titleStr to "测试dialog"
    set btns to {"按钮1", "按钮2", "按钮3"}
    display dialog titleStr buttons btns default button 1 --默认选择第1个按钮(按return时就会让弹出框消失)
    get the button returned of the result  -- 弹出框
    

    带文本输入的弹出框

    形式:
    display dialog 标题名 buttons 按钮标题列表 default button 按钮或序号 default answer 默认文本
    返回值也是record类型,格式:{button returned:"xxx", text returned:"xxx"}
    举例

    set titleStr to "测试文本输入框"
    set btns to {"button1", "button2", "button3"}
    display dialog titleStr buttons btns default button 1 default answer "这是默认文本"
    set returnRecord to the result --获取返回的record类型的值
    get the text returned of returnRecord  -- 获取输入的文本
    

    相关文章

      网友评论

          本文标题:AppleScript-dialog 弹出框

          本文链接:https://www.haomeiwen.com/subject/sxktvftx.html