Wednesday, March 20, 2019

#1 2019-03-01 06:03:49 pm

rfscripter
Member
From:: New Jersey, United States
Registered: 2014-04-20
Posts: 84
Website

acting on the result of a checkbox in Dialog Toolkit +

Hi all,

A frequent contributor to this site, Shane Stanley, developed an awesome script library, called Dialog Toolkit, that I've discovered recently and have been using to build out a custom dialog for an applet I've created. However, I'm trying to figure out how to put the result of a checkbox that I've created through this library back into my script to act on it. The snippet of code is below; any help would be greatly appreciated. The checkbox returns true or false values, which is perfect, but I need to find out which values specifically the checkbox is returning. I also would like to designate default and cancel buttons, which gives me an error every time I try to do so.

Thanks so much,

Rocco

Applescript:


use scripting additions
use script "Dialog Toolkit Plus" version "1.0"

set theMessage to "FloTools has detected that your current operating system is Mac OS Mojave. Due to Mojave's new security measures, you will be presented with multiple permission dialogs from this installer after proceeding. You must click OK in all of the dialogs that appear in order for FloTools to be properly installed." & return & "If the installer becomes busy or unresponsive for a long period of time, there may be a hiding system dialog that needs confirmation before continuing."
set {theCheckbox, theTop, newWidth} to create checkbox "I have read and understand the information in this dialog." bottom 0 max width 400 without initial state
repeat until result is true
   set {buttonName, suppressedState, controlsResults} to display enhanced alert "Security Alert:" message theMessage as informational alert buttons {"Cancel", "Next"} acc view width 650 acc view height theTop acc view controls {theCheckbox} without suppression
end repeat

Offline

 

#2 2019-03-02 03:53:52 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3367

Re: acting on the result of a checkbox in Dialog Toolkit +

I tested with a slightly modified code

Applescript:


use scripting additions
use script "Dialog Toolkit Plus" version "1.0"

set theMessage to "FloTools has detected that your current operating system is Mac OS Mojave. Due to Mojave's new security measures, you will be presented with multiple permission dialogs from this installer after proceeding. You must click OK in all of the dialogs that appear in order for FloTools to be properly installed." & return & "If the installer becomes busy or unresponsive for a long period of time, there may be a hiding system dialog that needs confirmation before continuing."
set {theCheckbox, theTop, newWidth} to create checkbox "I have read and understand the information in this dialog." bottom 0 max width 400 without initial state
repeat 5 times --until result is true
   set {buttonName, suppressedState, controlsResults} to display enhanced alert "Security Alert:" message theMessage as informational alert buttons {"another", "Annuler", "otherOne", "Next"} acc view width 650 acc view height theTop acc view controls {theCheckbox} without suppression
   log result
   log (class of controlsResults)
   
end repeat

Here is what I got:
checking the box & clicking Next
(*Next, false, true*)
(*list*)
checking the box & clicking otherOne
(*otherOne, false, true*)
(*list*)
checking the box and pressing return
(*Next, false, true*)
(*list*)
unchecking the box and clicking Annuler
(*Annuler, false, false*)
(*list*)
unchecking the box and pressing escape
(*Annuler, false, false*)
(*list*)

The state of the checkbox is item 1 of controlsResults
The default button is the last one of the given list of buttons.
The Cancel one is the button whose name is "Cancel" or the localized cancel string - in French it's "Annuler".
"Cancel" is accepted worlwide as the cancel button.

Applescript:

use scripting additions
use script "Dialog Toolkit Plus" version "1.0"

set theMessage to "FloTools has detected that your current operating system is Mac OS Mojave. Due to Mojave's new security measures, you will be presented with multiple permission dialogs from this installer after proceeding. You must click OK in all of the dialogs that appear in order for FloTools to be properly installed." & return & "If the installer becomes busy or unresponsive for a long period of time, there may be a hiding system dialog that needs confirmation before continuing."
set {theCheckbox, theTop, newWidth} to create checkbox "I have read and understand the information in this dialog." bottom 0 max width 400 without initial state
repeat 5 times --until result is true
   set {buttonName, suppressedState, controlsResults} to display enhanced alert "Security Alert:" message theMessage as informational alert buttons {"another", "Annuler", "otherOne", "Next"} acc view width 650 acc view height theTop acc view controls {theCheckbox} without suppression
   log result
   log ("the box is checked : " & item 1 of controlsResults)
   if buttonName is "Annuler" then exit repeat
end repeat

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 2 mars 2019 10:53:45

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)