Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: FastScripts and script editor discrepancies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FastScripts and script editor discrepancies



On 23 Jun 2016, at 9:31 AM, Christopher Stone <email@hidden> wrote:

On Jun 22, 2016, at 18:28, Shane Stanley <email@hidden> wrote:
FWIW, I think this is worth a bug report asking for the ability to choose which font to use via an extra optional parameter to display dialog. Because if you're tabulating stuff, the monospaced digits format so much better.


Hell yes!

Meanwhile, if you want to display tabulated data under 10.11, stick this in a library and use it (but if you're running Script Debugger, it must be version 6):

use AppleScript version "2.5" --  10.11 or later
use framework "Foundation"
use framework "AppKit"
use framework "Carbon" -- AEInteractWithUser() is in Carbon
use scripting additions
property returnCode : missing value

its showMessage:"21212" withTitle:"Read Me" textMaxWidth:350 withButtons:{"OK", "Cancel"}

on showMessage:theMessage withTitle:boldBit textMaxWidth:maxWidth withButtons:buttonsList
-- make attributed string system font with monospaced digits
set fontSize to current application's NSFont's systemFontSizeForControlSize:(current application's NSRegularControlSize)
set theFont to current application's NSFont's monospacedDigitSystemFontOfSize:fontSize weight:(current application's NSFontWeightRegular)
set attsDict to current application's NSDictionary's dictionaryWithObject:theFont forKey:(current application's NSFontAttributeName)
set attString to current application's NSAttributedString's alloc()'s initWithString:theMessage attributes:attsDict
-- make a text field to hold the message
set theField to (current application's NSTextField's alloc()'s initWithFrame:{{0, 0}, {100, 20}})
tell theField
(its setEditable:false)
(its setBordered:false)
its setDrawsBackground:false
its (cell()'s setWraps:true)
its setPreferredMaxLayoutWidth:maxWidth
its setAttributedStringValue:attString
end tell
-- make it fit; needs to be done on the main thread
my performSelectorOnMainThread:"fitToSizeView:" withObject:theField waitUntilDone:true
-- make sure we have permission
set theError to current application's AEInteractWithUser(-1, missing value, missing value) -- -1 is kAEDefaultTimeout
if theError is not 0 then error "User interaction disallowed" number theError
-- create an alert 
set theAlert to current application's NSAlert's alloc()'s init()
tell theAlert
its setMessageText:boldBit
repeat with anEntry in buttonsList
(its addButtonWithTitle:anEntry)
end repeat
its setAccessoryView:theField
end tell
-- show the alert; needs to be done on the main thread
my performSelectorOnMainThread:"showTheAlert:" withObject:theAlert waitUntilDone:true
set buttonNumber to returnCode mod 1000 + 1 -- where 1 = right-most button
set buttonName to item buttonNumber of buttonsList
return buttonName
end showMessage:withTitle:textMaxWidth:withButtons:

on showTheAlert:theAlert
-- check we are running in foreground
if not (current application's NSThread's isMainThread()) as boolean then error "This handler must be called on the main thread." from current application
set my returnCode to theAlert's runModal()
end showTheAlert:

on fitToSizeView:aView
aView's setFrameSize:(aView's fittingSize())
end fitToSizeView:



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Script Libraries (From: Jim Underwood <email@hidden>)
 >Re: Script Libraries (From: Shane Stanley <email@hidden>)
 >Re: Script Libraries (From: Jim Underwood <email@hidden>)
 >Re: Script Libraries (From: Shane Stanley <email@hidden>)
 >Re: Script Libraries (From: Jim Underwood <email@hidden>)
 >Re: Script Libraries (From: Shane Stanley <email@hidden>)
 >Re: Script Libraries (From: Jim Underwood <email@hidden>)
 >FastScripts and script editor discrepancies (From: 2551phil <email@hidden>)
 >Re: FastScripts and script editor discrepancies (From: Shane Stanley <email@hidden>)
 >Re: FastScripts and script editor discrepancies (From: Shane Stanley <email@hidden>)
 >Re: FastScripts and script editor discrepancies (From: Phil Stokes <email@hidden>)
 >Re: FastScripts and script editor discrepancies (From: Shane Stanley <email@hidden>)
 >Re: FastScripts and script editor discrepancies (From: Christopher Stone <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.