Hey Michael,
On Mar 08, 2014, at 13:12, Michael Grant <
email@hidden> wrote:
☞ If the user cancels, 'choose from list' returns {«class fals»:false}, not the string "false" — need to coerce to text (I haven't been able to get consistent results working with the chevron class).
Huh? You mean the boolean?
☞ Running my original version, the choose from list dialog didn't always have focus, so I couldn't use it without mousing. To rectify I put it inside the tell system events block with an activate command.
This is not a bad tactic, BUT if the user clicks outside of the dialog OR switches apps accidentally or otherwise you can lose your dialog and leaving it hanging.
-------------------------------------------------------------------------------------------
set l to {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"}
tell application (get name of application (path to frontmost application as text))
set theCoice to choose from list l ¬
with title "Your Dialog Title" with prompt "Pick 1 or More:" default items {item 1 of l} ¬
OK button name "Pick!" cancel button name "Be Gone!" multiple selections allowed true ¬
with empty selection allowed
if theCoice ≠ false and theCoice ≠ {} then
beep
# Do your thing...
end if
end tell
-------------------------------------------------------------------------------------------
It's a good practice to always include a try-on-error block.
-------------------------------------------------------------------------------------------
try
# Your code here...
on error e number n
set e to e & return & return & "Num: " & n
tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
if button returned of dDlg = "Copy" then set the clipboard to e
end try
-------------------------------------------------------------------------------------------
Handler for use with a library:
-------------------------------------------------------------------------------------------
try
# Your code here...
on error e number n
stdErr(e, n, true, true) of me
end try
-------------------------------------------------------------------------------------------
--» stdErr()
-------------------------------------------------------------------------------------------
-- Task: General error handler
-- dMod: 2013-05-31 : 04:22
-------------------------------------------------------------------------------------------
on stdErr(e, n, beepFlag, ddFlag)
set e to e & return & return & "Num: " & n
if beepFlag = true then
beep
end if
if ddFlag = true then
tell me
set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
end tell
if button returned of dDlg = "Copy" then set the clipboard to e
else
return e
end if
end stdErr
-------------------------------------------------------------------------------------------