Text entry field in dialog

(Shane Stanley) #1

Yes. But what you’re effectively asking for is the sort of thing my Dialog Toolkit script library provides, with more flexibility and defined terminology. So the code would be something like this:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
use dtLib : script "Dialog Toolkit" version "2.0"

set theMessage to "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!"
set {theField, theTop} to create field "" placeholder text "Enter your text here" left inset 0 bottom 0 field width 650 extra height 60
set {buttonName, suppressedState, controlsResults} to display enhanced alert "Many Buttons" message theMessage as informational alert buttons {"OK", "Five", "Four", "Three", "Two", "One", "Cancel"} giving up after 0 acc view width 650 acc view height theTop acc view controls {theField} without suppression

Which would produce a dialog like this:

As many buttons as you like
(Ed Stockly) #2

Dialog Toolkit doesn’t work for me here.

Script Debugger 6.0.1 (6A170) on OSX 10.10.4

I can make the Multiple buttons dialog run, but:

set theTextFieldSize to {{0, 0}, {650, 80}}

Changing these values seems to have no effect.

(Shane Stanley) #3

To avoid confusion, we’ve started a new Dialog Toolkit topic. I’ve moved your message here, although I see now your question actually relates to Phil’s code, which doesn’t use Dialog Toolkit.

Phil’s code sets the size, but it then runs a fitToSize: handler, so the final size reflects the amount of text.