InDesign CS6中的Applescript对话框:如何限制输入中的数字范围?

时间:2014-11-19 23:24:35

标签: applescript adobe-indesign

我有一个InDesign CS6的AppleScript对话框,它返回输入三个文本字段的值。这是相关的代码段

set userResponse to show myDialog
if userResponse is true then
    set docWidth to edit contents of myWidth as string
    set docHeight to edit contents of myHeight as string
    set docBleed to edit contents of myBleed as string
    destroy myDialog
else
    destroy myDialog
    error number -128
end if

我想添加以下逻辑并阻止用户输入大于2160的值。我只想显示该对话框,然后返回上一个对话框,以便他们可以纠正错误:

if 2160 < docWidth or docHeight then
    beep 1
    display alert "Document cannot be larger than 2160 inches in either dimension." buttons ["Try again"] default button 1
end if

我无法找到将其插入上一个对话框而不会破坏它的方法。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

之后不要尝试解决问题并定义符合您需求的UI。在这里,您希望用户给出整数值,因此您需要使用整数编辑框

set myWidth to make integer editboxes with properties {edit contents:"", min width:60, maximum value:2159, minimum value:1}
set myHeight to make integer editboxes with properties {edit contents:"", min width:60, maximum value:2159, minimum value:1}
set myBleed to make integer editboxes with properties {edit contents:"", min width:60, maximum value:2159, minimum value:1}

如果用户应该能够插入实际值,您可以使用真实编辑框

set myWidth to make real editboxes with properties {edit contents:"", min width:60, maximum value:2159, minimum value:1}
set myHeight to make real editboxes with properties {edit contents:"", min width:60, maximum value:2159, minimum value:1}
set myBleed to make real editboxes with properties {edit contents:"", min width:60, maximum value:2159, minimum value:1}

问候,迈克尔/汉堡