Error «doesn't understand suppressionButton()»

Hello,

My test script is as follows:

    use scripting additions
    use script "Dialog Toolkit Plus"
    try
    	try
    		set {LabelField, LabelID, LabeltoTop} to ¬
    			create top labeled field ¬
    				¬
    					"" placeholder text ¬
    				"Type some text..." bottom 5 ¬
    				left inset 30 ¬
    				field width 200 ¬
    				label text ¬
    				"Text value" extra height 1
    		
    		set {popupList, PopupToTop} to ¬
    			create popup {"Choose Me", "No Me", "Better ME!"} ¬
    				bottom LabeltoTop + 25 ¬
    				left inset 30 ¬
    				popup width 60
    	on error
    		return "Popup and labeled fields are invalid."
    	end try
    	
    	set {ButtonPressed, IsSuppr, _Values} to ¬
    		display enhanced alert ¬
    			"This is Alert!" suppression false ¬
    			message ¬
    			"The last action failed." buttons {"Cancel", "Really?", "OK"} ¬
    			acc view width 350 ¬
    			acc view height 400 ¬
    			acc view controls {LabelField, LabelID, LabeltoTop, ¬
    			popupList, PopupToTop}
    on error errMsg number errNum
    	return "Enhanced alert completed with an error." & return & return & "Error " & errNum & "," & return & "Error says: " & errMsg
    end try

I enclosed it in error traps. Running it I always get the second error alert complemented by the app event error

Error: the AppleEvent was not handled by any handler (errAEEventNotHandled:-1708).

that in the AppleScript version appears as

"Enhanced alert completed with an error.

Error -1708,
Error says: {«class ocid» id «data optr000000008090EA0000600000», 104.0} doesn’t understand the “suppressionButton” message."

Why? I draw on the sample script just with some commands omitted. I created a control I handed over to the display enhanced alert command. All conditions have been met. Why do I still get this error?

It’s this line:

labelID, LabelToTop and popupToTop are not ACC view controls.
(Edit: should have said this: LabelToTop and popupToTop are not ACC view controls.)
Use just the first item of those commands to get the ACC view controls. (Edit: Some of those commands return two ACC view controls, see my post below)

use scripting additions
use script "Dialog Toolkit Plus"
try
   try
      set {LabelField, LabelID, LabeltoTop} to ¬
         create top labeled field ¬
            ¬
               "" placeholder text ¬
            "Type some text..." bottom 5 ¬
            left inset 30 ¬
            field width 200 ¬
            label text ¬
            "Text value" extra height 1
      
      set {popupList, PopupToTop} to ¬
         create popup {"Choose Me", "No Me", "Better ME!"} ¬
            bottom LabeltoTop + 25 ¬
            left inset 30 ¬
            popup width 60
   on error
      return "Popup and labeled fields are invalid."
   end try
   
   set {ButtonPressed, IsSuppr, _Values} to ¬
      display enhanced alert ¬
         "This is Alert!" suppression false ¬
         message ¬
         "The last action failed." buttons {"Cancel", "Really?", "OK"} ¬
         acc view width 350 ¬
         acc view height 400 ¬
         acc view controls {LabelField, ¬
         popupList}
on error errMsg number errNum
   return "Enhanced alert completed with an error." & return & return & "Error " & errNum & "," & return & "Error says: " & errMsg
end try

  1. Why aren’t they accessory view controls?
  2. If they aren’t then what are they for and how to use them correctly?
  3. How is it that these objects are in Jim Underwood’s sample script showing the dialog containing these objects?

Those are good questions, and Shane can better answer them than me, but I’ll have a go.

The ACC View controls are the objects that are created by the “create” commands. The others are parameters of those objects.

That said, I mistated it. Some create accessory view commands generate a single accessory view, others, including “create top labeled field” generate two accessory views. If you look at the entry in the dictionary …

create top labeled field
create top labeled field (verb)Create an entry field with a single-line label at the top. (from Alert Suite)
FUNCTION SYNTAX
set theResult to create top labeled field text ¬
     placeholder text any ¬
     left inset integer ¬
     bottom integer ¬
     field width integer ¬
     extra height integer ¬
     label text text
RESULT
list of any A list containing the field, the label, and the distance from the top of the label to the bottom of the accessory view.

Under “Result” you’ll see
The field and the Label are the accessory view controls.

The third value is the height of the accessory views.

The height is important. Think of building your dialog from the ground up.

Each create accessory view command has a “bottom” parameter. You could start that as 1 or 0.

When you get the result of the accessory view command you get a value for it’s height. Add that to the bottom and you get the top of the current view in the dialog, which you can then use that as the bottom parameter for the next view (or add a spacer if you like, as you do in your script) and then each accessory view will appear above the previous one your dialog.

Also some of the accessory commands return a width of that view, which you can use to make sure that the dialog is wide enough to show the widest view but not too wide.

Looking at the dictionary entries it seems that every create command generates at least one view control. Most of the label commands have two. All create commands return a height value and some (those that need it) return a width value.

Jim’s sample probably used a label commands (the only ones that generate two controls).

How to tell if a create command returns two view controls or one? You can look at the dictionary entry for the command, or execute the command and examine the result in the result pane.

Here’s the result for your create top labeled field command:

{<NSTextField: 0x7fdf7cffe960>, <NSTextField: 0x7fdf7cfdecb0>, 53.0}

You can see you’re getting two accessory view controls and one dimension diameter (height). If there are two dimensions returned, the last is always width and next to last is always height.

Hope that answers everything.

Also, I’m not sure which of Jim’s samples you’re referring to, can you post a link?

I think I cracked the enigma. It’s simpler than I thought.

Every Dialog ToolKit+ command returns a list containing objects and data. Objects are represented by the specifier either in the Obj-C notation or as the raw AppleScript syntax like class «[any_identifier]» and come as a part of the description in the Dictionary as in

A list containing the field, the label

The field and label are the objects we’re interested in whereas

the distance from the top of the label to the bottom of the accessory view

refers to data which is used as a measurement for spatial arrangement of these objects in the body of the dialog. Therefore it doesn’t belong to the dialog building command.

The two commands that build the dialog actually, take only the objects not data. If one is to think along these lines then it makes sense. I just wish the documentation wasn’t so sparse.