text stringlengths 0 15.7k | source stringlengths 6 112 |
|---|---|
property returnCode : missing value | lns3.scpt |
property handlerResult : missing value | lns3.scpt |
on display enhanced window windowTitle acc view width theWidth acc view height theHeight acc view controls controlsList giving up after giveUp : 0 active field defaultField : missing value initial position initPosition : {} align cancel button cancelLeftFlag : true buttons allButtons | lns3.scpt |
set theError to current application's AEInteractWithUser(-1, missing value, missing value) -- -1 is kAEDefaultTimeout | lns3.scpt |
if theError is not 0 then | lns3.scpt |
error "User interaction disallowed" number theError | lns3.scpt |
if NSThread's isMainThread() as boolean then | lns3.scpt |
my prepareEnhancedWindowMainThread:{windowTitle, theWidth, theHeight, controlsList, giveUp, defaultField, initPosition, cancelLeftFlag, allButtons} | lns3.scpt |
set theWindow to handlerResult | lns3.scpt |
my showTheWindowAndWaitMainThread:{theWindow, defaultField, giveUp, initPosition, windowTitle} | lns3.scpt |
my performSelectorOnMainThread:"prepareEnhancedWindowMainThread:" withObject:{windowTitle, theWidth, theHeight, controlsList, giveUp, defaultField, initPosition, cancelLeftFlag, allButtons} waitUntilDone:true | lns3.scpt |
my performSelectorOnMainThread:"showTheWindowAndWaitMainThread:" withObject:{theWindow, defaultField, giveUp, initPosition, windowTitle} waitUntilDone:true | lns3.scpt |
set handlerResult to missing value | lns3.scpt |
set buttonNumber to returnCode | lns3.scpt |
if buttonNumber = NSModalResponseCancel then error number -128 -- designated Cancel button pressed | lns3.scpt |
if buttonNumber = NSModalResponseAbort then -- timed out | lns3.scpt |
set buttonName to "Gave Up" | lns3.scpt |
set buttonName to (item buttonNumber of allButtons)'s title() as text | lns3.scpt |
set controlResults to {} | lns3.scpt |
repeat with aControl in controlsList | lns3.scpt |
if (aControl's isKindOfClass:(NSTextField)) as boolean then | lns3.scpt |
set end of controlResults to aControl's stringValue() as text | lns3.scpt |
(aControl's setDelegate:(missing value)) | lns3.scpt |
else if (aControl's isKindOfClass:(NSPopUpButton)) as boolean then | lns3.scpt |
set end of controlResults to aControl's titleOfSelectedItem() as text | lns3.scpt |
else if (aControl's isKindOfClass:(NSButton)) as boolean then | lns3.scpt |
set end of controlResults to aControl's state() as boolean | lns3.scpt |
else if (aControl's isKindOfClass:(NSPathControl)) as boolean then | lns3.scpt |
set end of controlResults to aControl's |URL|()'s |path|() as text | lns3.scpt |
else if (aControl's isKindOfClass:(NSMatrix)) as boolean then | lns3.scpt |
set end of controlResults to aControl's selectedCell()'s title() as text | lns3.scpt |
else if (aControl's isKindOfClass:(NSImageView)) as boolean then | lns3.scpt |
set end of controlResults to aControl's image()'s |name|() as text | lns3.scpt |
else -- NSBox | lns3.scpt |
set end of controlResults to missing value | lns3.scpt |
set my returnCode to missing value | lns3.scpt |
return {buttonName, controlResults} | lns3.scpt |
end display enhanced window | lns3.scpt |
on create buttons buttonList button keys buttonKeysList : {} equal widths equalWidths : (false) default button okIndex : 0 cancel button cancelIndex : 0 | lns3.scpt |
my createButtonsViewMainThread:{buttonList, buttonKeysList, equalWidths, cancelIndex, okIndex} | lns3.scpt |
my performSelectorOnMainThread:"createButtonsViewMainThread:" withObject:{buttonList, buttonKeysList, equalWidths, cancelIndex, okIndex} waitUntilDone:true | lns3.scpt |
return handlerResult | lns3.scpt |
end create buttons | lns3.scpt |
on display enhanced alert mainText message theExplanation as styleType : informational alert buttons buttonsList suppression showSuppression : false giving up after giveUp : 0 acc view width theWidth acc view height theHeight acc view controls controlsList | lns3.scpt |
if styleType = critical alert then | lns3.scpt |
set styleNum to 2 | lns3.scpt |
else if styleType = warning alert then | lns3.scpt |
set styleNum to 0 | lns3.scpt |
set styleNum to 1 | lns3.scpt |
my displayEnhancedAlertMainThread:{mainText, theExplanation, styleNum, buttonsList, showSuppression, giveUp, theWidth, theHeight, controlsList} | lns3.scpt |
my performSelectorOnMainThread:"displayEnhancedAlertMainThread:" withObject:{mainText, theExplanation, styleNum, buttonsList, showSuppression, giveUp, theWidth, theHeight, controlsList} waitUntilDone:true | lns3.scpt |
if giveUp > 0 and returnCode is not NSModalResponseAbort then NSObject's cancelPreviousPerformRequestsWithTarget:(NSApp) selector:"abortModal" object:(missing value) | lns3.scpt |
set theAlert to handlerResult | lns3.scpt |
set suppressedState to theAlert's suppressionButton()'s state() as boolean | lns3.scpt |
set buttonNumber to returnCode mod 1000 + 1 -- where 1 = right-most button | lns3.scpt |
if buttonNumber = 0 then | lns3.scpt |
set buttonName to item buttonNumber of (reverse of buttonsList) | lns3.scpt |
return {buttonName, suppressedState, controlResults} | lns3.scpt |
end display enhanced alert | lns3.scpt |
on create label labelString left inset theLeft : 0 bottom theBottom max width maxWidth aligns alignment : left aligned multiline wrapsBool : true control size controlSize : regular size bold type boldType : false | lns3.scpt |
my createLabelMainThread:{labelString, theLeft, theBottom, maxWidth, alignment, wrapsBool, controlSize, boldType} | lns3.scpt |
my performSelectorOnMainThread:"createLabelMainThread:" withObject:{labelString, theLeft, theBottom, maxWidth, alignment, wrapsBool, controlSize, boldType} waitUntilDone:true | lns3.scpt |
end create label | lns3.scpt |
on max width for labels listOfLabels control size controlSize : regular size bold type boldType : false | lns3.scpt |
set theFont to my fontOfControlSize:controlSize boldType:boldType | lns3.scpt |
set theAtts to NSDictionary's dictionaryWithObject:theFont forKey:(NSFontAttributeName) | lns3.scpt |
set maxWidth to 0 | lns3.scpt |
repeat with labelString in listOfLabels | lns3.scpt |
set theString to (NSString's stringWithString:labelString) | lns3.scpt |
set newWidth to width of (theString's sizeWithAttributes:theAtts) | lns3.scpt |
if newWidth > maxWidth then set maxWidth to newWidth | lns3.scpt |
return maxWidth + 4.5 -- allow for frame rectangle and fudge | lns3.scpt |
end max width for labels | lns3.scpt |
on max depth for label labelText max width maxWidth control size controlSize : regular size bold type boldType : false | lns3.scpt |
set labelText to NSString's stringWithString:labelText | lns3.scpt |
set theFrame to labelText's boundingRectWithSize:{maxWidth, 2000} options:NSStringDrawingUsesLineFragmentOrigin attributes:theAtts | lns3.scpt |
if class of theFrame is record then | lns3.scpt |
set theHeight to height of |size| of theFrame | lns3.scpt |
set theHeight to item 2 of item 2 of theFrame | lns3.scpt |
return theHeight + 1 -- allow fudge | lns3.scpt |
end max depth for label | lns3.scpt |
on create field enteredText placeholder text placeholder : "" left inset theLeft : 0 bottom theBottom field width theWidth extra height extraHeight : 0 accepts linebreak and tab acceptsTabs : false | lns3.scpt |
my createFieldMainThread:{enteredText, placeholder, theLeft, theBottom, theWidth, extraHeight, acceptsTabs} | lns3.scpt |
my performSelectorOnMainThread:"createFieldMainThread:" withObject:{enteredText, placeholder, theLeft, theBottom, theWidth, extraHeight, acceptsTabs} waitUntilDone:true | lns3.scpt |
end create field | lns3.scpt |
on create secure field enteredText placeholder text placeholder : "" left inset theLeft : 0 bottom theBottom field width theWidth | lns3.scpt |
my createSecureFieldMainThread:{enteredText, placeholder, theLeft, theBottom, theWidth} | lns3.scpt |
my performSelectorOnMainThread:"createSecureFieldMainThread:" withObject:{enteredText, placeholder, theLeft, theBottom, theWidth} waitUntilDone:true | lns3.scpt |
end create secure field | lns3.scpt |
on create top labeled field enteredText placeholder text placeholder : "" left inset theLeft : 0 bottom theBottom field width theWidth extra height extraHeight : 0 label text theLabel accepts linebreak and tab acceptsTabs : false | lns3.scpt |
set {theField, theTop} to create field enteredText placeholder text placeholder left inset theLeft bottom theBottom field width theWidth extra height extraHeight accepts linebreak and tab acceptsTabs | lns3.scpt |
set {theLabel, theTop, newWidth} to create label theLabel left inset theLeft bottom (theTop + 8) max width theWidth aligns left aligned without multiline | lns3.scpt |
return {theField, theLabel, theTop} | lns3.scpt |
end create top labeled field | lns3.scpt |
on create side labeled field enteredText placeholder text placeholder : "" left inset theLeft : 0 bottom theBottom total width theWidth label text theLabel field left fieldLeft accepts linebreak and tab acceptsTabs : false | lns3.scpt |
if fieldLeft ≤ theLeft then | lns3.scpt |
set {theLabel, theTop, newWidth} to create label theLabel left inset theLeft bottom (theBottom + 4) max width theWidth aligns left aligned without multiline | lns3.scpt |
set fieldLeft to (theLeft + newWidth + 8) | lns3.scpt |
set {theField, theTop} to create field enteredText placeholder text placeholder left inset fieldLeft bottom theBottom field width (theWidth - newWidth - 8) extra height 0 accepts linebreak and tab acceptsTabs | lns3.scpt |
set {theLabel, theTop, newWidth} to create label theLabel left inset theLeft bottom (theBottom + 4) max width (fieldLeft - theLeft - 8) aligns right aligned without multiline | lns3.scpt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.