0

I have an applescript dialog for InDesign CS6 that returns values entered into three text fields. Here's the relevant snippet

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

I want to add the following logic and prevent the user from entering in values larger than 2160. I just want this dialog to display and then return to the previous dialog so they can correct the error:

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

I can't find a way to insert this into the previous dialog without destroying it. Any ideas?

1 Answers1

2

Don't try to solve problems afterwards and define your UI matching your needs. Here you want the user to give integer values, so you need to use integer editboxes:

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}

If the user should be able to insert real values you can use real edit boxes:

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}

Greetings, Michael / Hamburg

ShooTerKo
  • 2,242
  • 1
  • 13
  • 18
  • I didn't know there was such a thing as an integer editbox, nor did I know that I could set minimum and maximum values. Thanks! – Patrick Hennessey Nov 20 '14 at 17:51
  • You find all the UI elements and their properties inside of InDesign's Scripting Dictionary under the topic UI Suite. Maybe you find something better or you want the user to be able to click up and down arrows like in InDesign itself. – ShooTerKo Nov 20 '14 at 20:24
  • I've looked there -- it's a mess of a million entries -- not that easy to use. Thanks for your help! – Patrick Hennessey Nov 20 '14 at 22:20