I am currently making an AppleScript and would like to know how to do the following things.
- Display text in the center of a
display dialog
- How to create a new line inside the dialog
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Sign up to join this communityTo create a second line use \n
or just hit enter when you want the new line:
display dialog "Test\nTest2"
or
display dialog "Test
Test2"
About the center alignment, I think that is not possible.
You can use CocoaAppleScript to do this. Create one by going into Script Editor's "New from Template" menu in the File menu, and "Cocoa-AppleScript Applet.app". Modify html_data's HTML code to get it to be how you want it. Try it out!:
set alert to current application's NSAlert's new
set alert's messageText to ""
set text_field to current application's NSTextField's alloc's initWithFrame:NSMakeRect(0, 0, 300, 88)
set text_field's drawsBackground to false
set text_field's editable to false
set text_field's bezeled to false
set html_data to (current application's NSString's stringWithString:("<center><font size=\"80\">Welcome!<br>Another welcome!</font></center>"))'s dataUsingEncoding:(current application's NSUTF8StringEncoding)
set text_field's attributedStringValue to (current application's NSAttributedString's alloc's initWithHTML:html_data documentAttributes:(current application's NSDictionary's dictionaryWithObject:(current application's NSFont's fontWithName:"Palatino-Roman" |size|:12) forKey:(current application's NSFontAttributeName)))
set alert's accessoryView to text_field
alert's runModal