New versions of Dialog Toolkit

Display Enhanced Window:

  • The beep when clicking on any button is still there.
  • The window title does not appear here (El Capitan).
  • if the dock is present, an initial position of {100,100} will place the window at {100,190}

I have a more “philosophical” question:
Why when clicking on the cancel button, the behavior is not the same if using display enhanced alert or display enhanced window?
I don’t mean it should be as before…

Will fix.

Can you post a screenshot (say, Simple Sample).

I’m open to argument. My feeling is that it should throw error number -128, but that it’s a bit late to change it now for the alert. Maybe I should just change it for the alert. (To be honest, my feeling is that the alert generally doesn’t make much sense any more.)

Any thoughts (from you or anyone else)?

No, that’s too strong. It fulfils a less frequent requirement.

I agree with that.
But then I think we’ll miss the icon.

Here’s the screenshot with your simple sample:

To be honnest, if the only difference with the “window” version is to avoid the display of informative text and icon, I can say I will never use it.
But I can imagine why others want it.
If you maintain DT “Standard” (adding new parameters as optional everytime it’s possible), DT Plus could only hold the “window” version.

But you’re the master of game!

There’s also much greater control over the buttons. And extra width, if needed.

Would you mind inserting this code after the line theWindow’s setAutorecalculatesKeyViewLoop:true`, and tell me what appears?

set theTitle to theWindow's title()
display dialog theTitle as text

The dialog shows the actual title.

Shane, the Enhanced Window dialog solves two problems for me: positioning multiple dialogs on the screen so they don’t overlap and setting the default location for the active field.

I’ll be testing ASAP.

I’ll miss not having an icon but, hoping that there might be a way in the future to add an image.

Many thanks.

Cheers.

I was afraid you say that :disappointed:

This is a long-shot — try adding:

	theWindow's setTitlebarAppearsTransparent:false

There’s no reason you can’t add your own images:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions
use script "Dialog Toolkit Plus" version "1.0"

set accViewWidth to 650

set {theButtons, minWidth} to create buttons {"Cancel", "Five", "Four", "Three", "Two", "One", "OK"} button keys {"", "5", "4", "3", "2", "1", ""} cancel button 1 default button 7
if minWidth > accViewWidth then set accViewWidth to minWidth -- make sure buttons fit
set {theField, theTop} to create field "" placeholder text "Enter your text here" bottom 0 field width accViewWidth extra height 60 with accepts linebreak and tab
set {boldLabel, theTop} to create label "How many buttons would you like? There's no real limit except for practical and aesthetic considerations." & return & "Of course, I hope you'll never really think about using something as ugly as this!" & return & return & "Choose your heart out!" & return & return & "Also, try the command-1 thru command-5 button shortcuts." bottom theTop + 20 max width accViewWidth control size regular size
set theImage to current application's NSImage's alloc()'s initWithContentsOfFile:"/Users/shane/Desktop/Test 128 Code.tif" -- change to suit
set imageView to current application's NSImageView's alloc()'s initWithFrame:{{0, theTop + 8}, {accViewWidth, 100}}
imageView's setImage:theImage
imageView's setImageScaling:(current application's NSImageScaleProportionallyUpOrDown)
set {buttonName, controlsResults} to display enhanced window "Many Buttons" acc view width accViewWidth acc view height theTop + 108 acc view controls {theField, boldLabel, imageView} button list theButtons active field theField initial position {0, 0} with align cancel button

1 Like

No go.

I changed the widow style to:

 property NSTitledWindowMask : a reference to 1 + 2 + 4 + 8

I wanted to se if the title bar accepts modifications.
The 3 buttons are there and functional.

Is it a bug in El Capitan?

OK, that’s way better than using the default icon in NSAlert. Now I can position and size the image. I did find NSImage in Apple’s documentation but it would have taken me days/weeks to figure out how to get it working.

Many thanks.

I fear so. Your test shows the title is being set, just not showing.

Anyone here able to try it in 10.10?

Here’s a new version.

See below.

I’m sticking with error number -128 for the window and not for the alert because it gets too icky to do otherwise. To wean people off alerts, I’ve added a new create image view command — see the new example.

I’ve also fixed (I hope) the positioning issue.

This solves my problem with trying to save a script file with C and Objective-C pointers.

Now I can’t get rid of an error “Syntax Error Expected end of line etc. but found identifier” on this line:

set {imageView, theTop} to create image view imagePath bottom theTop + 20 view width 64 view height 64 scale image scale proportionally

Code works without it but can’t compile with it. After a few saves, Script Editor freezes. Also getting an error on C and Objective-C pointers but, I don’t think I have any in the code.

Sample code works for me so, I’m banging on my code trying to find my goof. And it’s a perfect pain. I’ve got the code working in a test script. I then copied and pasted the code back to my app but still get the syntax error. More trial and error to come. [Edited to add test script results]

Fixed - had an old version of DT+ in the app’s script library - just another newbie fail.

Yep. Works fine here.

For the title not showing, the following may help to find a workaround:

grab-001

Interesting. The docs definitely say that -initWithContentRect:styleMask:backing:defer: is the designated initializer, so I’m a little hesitant. Let me try something else…

Shane, I’m getting an error “Can’t get character 1 of “”.” number -1728 from character 1 of “”

with this line:

set {theButtons, minWidth} to create buttons {“Help”, “Options”, “Quit”, “Download”} button keys {"", “2”, “q”, “”} default button 4

No error if I add cancel button 1 to that line. Also, no error if I assign a key to the only button not given a key ie.:

set {theButtons, minWidth} to create buttons {“Help”, “Options”, “Quit”, “Download”} button keys {“h”, “2”, “q”, “”} default button 4

Another issue: I can’t get the label text to show with this line:

set {thePathControl, pathLabel, theTop} to create labeled path control (POSIX path of savingFolder_Path) left inset 0 bottom (theTop + 8) control width accViewWidth label text “Change folder for saving ?” with pops up

Have tried lifting the control above but get more empty space.

Cheers

Thanks — will fix.

Can you email me the complete script?