I’ll send you a bunch in the morning, I usually have half a dozen
So the app continued to crash, but without the appleCrash report appearing. I ran it from within SD and that generated the SD crash report which I sent from within the app.
Not so much a question but more of a feature request.
Would it be difficult to allow an icon to be displayed with a table? Not in the table itself, but in the window the way it’s done with display dialog and display alert.
(I have two identical scripts, one that controls Safari, the other Chrome, I’d like to have an icon displaying in the window to let the user know at a glance which one to click on)
It’s more work than I want to take on, honestly. But you can pretty much do what you like with the accessory view.
Create an image view and fill it with your pic (doesn’t need to be .icns file):
set theImage to current application's NSImage's alloc()'s initWithContentsOfURL:theFile
set theView to current application's NSImageView's alloc()'s initWithFrame:{{0, 0}, {64, 64}}
theView's setImage:theImage
theView's setImageScaling:(current application's NSImageScaleProportionallyUpOrDown)
Then pass that as the accessory view
. The placement is a bit odd, above the buttons, but it should get the message across.
OK, I’ll try that. thanks.
Quick question about adding a row. Is it possible to ad a row with default values? I have a table where only one or two of several variables need to change when the user click +, but they have to fill them all in.
It’s theoretically possible…
When “OK Button is default” is set to true, shouldn’t the OK button be highlighted? It’s not, but it’s still default. (it activates when you hit return)
That’s the OS’s doing, I’m afraid.
The script below is part of a large script that’s nearly complete. But it has one nagging issue. It displays a table with two columns and the first column is basically labels and doesn’t need much space. The second column is data, and needs more space.
I’ve tried numerous combinations of
modify columns column width
and
modify table column widths pattern
But I can’t get the first column to be narrow and the second column to be wide.
Any suggestions?
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use script "Myriad Tables Lib"
use script "Dialog Toolkit Plus"
set initialPosition to {30, 30}
set titleLists to {¬
{"dataTitle", "Category", "Channel", true, ¬
"PreferredTitle", ¬
"TitleOption1", ¬
"TitleOption2", ¬
"TitleOption3", ¬
"TitleOption4", ¬
"TitleOption5"}, ¬
{"Two and a Half Men", "Series -- Syndicated", "", false, ¬
"2 & 1/2 Men"}, ¬
{"Last Man Standing", "Series -- First Run and Syndicated", "Fox", false, ¬
"Last Man Standing", ¬
"Last Standing"}, ¬
{"The Daily Show With Trevor Noah", "Series -- First Run", "Comedy Central", false, ¬
"The Daily Show With Trevor Noah", ¬
"The Daily Show: Trevor Noah", ¬
"Daily Show: Trevor Noah", ¬
"The Daily Show", ¬
"Trevor Noah", ¬
"Daily Show"}, ¬
{"Saturday Night Live", "Series -- First Run and Syndicated", "NBC", false, ¬
"Saturday Night Live", ¬
"SNL"} ¬
}
repeat
set titleInfo to some item of titleLists
set {thisTitle, category, channel, episodeTitles} to titleInfo
set titleOptionlist to items 5 through -1 of titleInfo
set item 1 of titleOptionlist to {"Preferred", item 1 of titleOptionlist}
repeat with x from 2 to count of titleOptionlist
set thisTitleOption to item x of titleOptionlist
set thisTitleOption to {"Alt-" & ((x - 1) as text), (thisTitleOption as text)}
set item x of titleOptionlist to thisTitleOption
end repeat
set rowTemplate to {"", ""}
set selectedRows to {}
set tableTitle to thisTitle & " title options"
set theCategory to category
set theChannel to channel
--set viewParams to BuildAcceccoryView(episodeTitles, theCategory, theChannel)
--
--my CreateAccessory(viewParams)
--
-- create accessory view, passing controls plus size (as {width, height})
set tablePrompt to "Edit info and options for " & thisTitle
set theTable to make new table with data titleOptionlist ¬
with title tableTitle ¬
with prompt tablePrompt ¬
multiple selections allowed false ¬
empty selection allowed true ¬
row template rowTemplate ¬
can add and delete true ¬
editable columns {2} ¬
column headings {"", "Title Options"} ¬
row numbering false ¬
initially selected rows selectedRows
set OKButton to "Save" --1
set CancelButton to "Cancel (without saving)" --ERROR
set extraButton to "Edit" --2
modify table theTable ¬
OK button name OKButton ¬
cancel button name CancelButton ¬
extra button name extraButton ¬
highlighted rows {} ¬
grid style grid between columns ¬
column widths pattern {1, 2} ¬
alternate backgrounds true ¬
initial position initialPosition ¬
row dragging false ¬
without column reordering
-- modify table theTable accessory view theAccessoryView
modify columns in table theTable ¬
columns list {1} ¬
column width 5
modify columns in table theTable ¬
columns list {2} ¬
column width 35
try
set tableResult to display table theTable ¬
with extended results
on error errMsg number errNum
exit repeat
end try
end repeat
The ‘column widths pattern’ parameter is to set equal columns; it’s no use for what you’re trying to do. And your column width values are being ignored because they’re way too small. Try values of 50 and 350 instead.
Thanks, that put me on the right track.
modify columns in table theTable ¬
columns list {2} ¬
column width 480
--modify columns in table theTable ¬
-- columns list {1} ¬
-- column width 10
So, I figured out that if I drop the column widths patterns parameter, and just set the width of the longer column, the shorter column will fill the rest of the space.
Thanks!
Now I’m off to storing and retrieving from multiple applications in SQL Lite!
I have a script using Myriad Tables that I have been using for years, with a few updates or added features now and then. (This go around I added a Dialog toolkit dialog).
It has worked fine as an applet and in ScriptDebugger.
But with my last edit there’s a bug, so I need to use the debugger.
As soon as it reaches the “Display table with data” command I get this AppleScript Execution error message:
Couldn’t write data because C and Objective-C pointers cannot be saved in scripts.
I believe all the variables used in the command are local to its hander.
Plus, when it’s not in debugging mode the table displays perfectly, and, in this script, it’s in a repeat loop so the user can verify the changes, and it displays correctly subsequently. The bug comes later in execution.
How can I track down what’s causing this?
→ Script Debugger 7.0.13 (7A125)
→ Mac OS 10.13.6 (17G14042)
→ “Myriad Tables Lib” version “1.0.9”
Dang, I thought this looked familiar. A search turned up the answer that tables use pointers that can’t be saved.
It’s strange because I use debugging so much and Myriad Tables so much I’m surprised I don’t see this all the time.
My workaround is to save an applet with the handler in it’s own app (tableapp.app) and, when debugging, call the handler in that app.
Funny thing is I am able to debug MT scripts on my work Mac.
→ Script Debugger 7.0.13 (7A125)
→ Mac OS 10.11.6 (15G22010)
–>“Myriad Tables Lib” version “1.0.11”
(Just realized I need to upgrade MT on my laptop too)
OK, This is weird.
I would get the pointers message on my old Laptop
→ Script Debugger 7.0.13 (7A125)
→ Mac OS 10.13.6 (17G14042)
→ “Myriad Tables Lib” version “1.0.9”
But not on my Mac mini
→ Script Debugger 7.0.13 (7A125)
→ Mac OS 10.11.6 (15G22010)
–>“Myriad Tables Lib” version “1.0.11”
But I get it on my new laptop
→ Script Debugger 8.0.1 (8A36)
→ Mac OS 11.6 (20G165)
–>“Myriad Tables Lib” version “1.0.12”
I understand why it doesn’t work on the laptops, but how is it that it works on the Mac mini?
I feel I’m very close to adding an accessory view field to a table, but it’s not working. I’m getting a blank space.
What am I missing?
use AppleScript version "2.4"
use framework "Foundation"
use framework "AppKit"
use script "Myriad Tables Lib" version "1.0.9"
use scripting additions
property theAccessoryView : missing value
property theField : missing value
if current application's NSThread's isMainThread() as boolean then
my createFieldMainThread:{"entered Text", "place holder text", 20, 20, 200, 200, true}
my buildAccessoryViewMainThread:{theField}
else
my performSelectorOnMainThread:"createFieldMainThread:" withObject:{"enteredText", "placeholder", 0, 0, 200, 20, true} waitUntilDone:true
my performSelectorOnMainThread:"buildAccessoryViewMainThread:" withObject:{theField} waitUntilDone:true
end if
set theTable to make new table with data {"One", "Two", "Three", "Four", "Five"}
modify table theTable accessory view theAccessoryView
set theAccessoryView to missing value -- to avoid error messages when saving
display table theTable
on createFieldMainThread:theArg
set {enteredText, placeholder, theLeft, theBottom, theWidth, extraHeight, acceptsTabs} to theArg as list
set theTop to theBottom + 22 + extraHeight
set theField to (NSTextField's alloc()'s initWithFrame:{{theLeft, theBottom}, {theWidth, theTop - theBottom}})
tell theField
(its setEditable:true)
(its setBezeled:true)
its (cell()'s setPlaceholderString:placeholder)
if extraHeight > 0 then its (cell()'s setWraps:true)
its setStringValue:enteredText
if acceptsTabs then its setDelegate:me
end tell
-- return theField, the top of the field
set my handlerResult to {theField, theTop}
end createFieldMainThread:
on buildAccessoryViewMainThread:theControls
set my theAccessoryView to current application's NSView's alloc()'s initWithFrame:{{0, 0}, {160, 60}}
repeat with aControl in theControls
(theAccessoryView's addSubview:aControl)
end repeat
end buildAccessoryViewMainThread:
I think I figured out what I was missing: Dialog Toolkit Plus!
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "Carbon" -- AEInteractWithUser() is in Carbon
use script "Myriad Tables Lib" version "1.0.12"
use script "Dialog Toolkit Plus" version "1.1.2"
property theAccessoryView : missing value
--accView variables
set accViewControls to {}
set AccViewLeft to 0
set AccViewBottom to 0
set AccViewWidth to 200
set AccViewTop to 250
set theBottom to AccViewBottom
set theLeft to AccViewLeft
set spacer to 20
--Label variables
set maxWidth to 200
set alignment to center aligned
-- alignments: left aligned, right aligned or center aligned
set wrapsBool to true
set controlSize to regular size
--control sizes:regular size, mini size, small size,large size
set boldType to true
set labelString to "The Label Text"
--Field variables
set enteredText to "Entered Text"
set defaultText to "Place holder text"
set theWidth to 200
set extraHeight to spacer
set acceptsTabs to true
--View variables
set iconPath to choose file with prompt ("Select the image to display") ¬
of type ("jpg") with showing package contents
set posixPath to POSIX path of iconPath
--set posixPath to "/Users/edstockly/AppleScript/Handlers and Snippets/MyriadTableAccessoryView/seachSafariIcon.jpg"
set viewWidth to 40
set viewHeight to 40
set imageScale to scale to fit
--{scale down proportionally, scale to fit, scale none, scale proportionally}
set imageAlignment to bottom aligned
--imageAlignments:center aligned, top aligned, top left aligned, top right aligned
----left aligned, bottom left aligned, bottom right aligned, right aligned, bottom aligned
set {theField, theTop} to create field enteredText ¬
placeholder text defaultText ¬
left inset theLeft ¬
bottom theBottom ¬
field width theWidth ¬
extra height extraHeight ¬
with accepts linebreak and tab
set the end of accViewControls to theField
set theBottom to theTop
set {theLabel, theTop} to create label labelString ¬
left inset theLeft ¬
bottom theBottom ¬
max width maxWidth ¬
aligns alignment ¬
multiline wrapsBool ¬
control size controlSize ¬
bold type boldType
set the end of accViewControls to theLabel
set theBottom to theTop + spacer
set {theImage, theTop} to create image view posixPath ¬
left inset theLeft ¬
bottom theBottom ¬
view width viewWidth ¬
view height viewHeight ¬
scale image imageScale ¬
align image imageAlignment
set the end of accViewControls to theImage
set theTop to theTop - AccViewBottom
if theTop < AccViewTop then set AccViewTop to theTop
my buildAccessoryViewMainThread:{accViewControls, AccViewLeft, AccViewBottom, AccViewWidth, AccViewTop}
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
if NSThread's isMainThread() as boolean then
my createLabelMainThread:{labelString, theLeft, theBottom, maxWidth, alignment, wrapsBool, controlSize, boldType}
else
my performSelectorOnMainThread:"createLabelMainThread:" withObject:{labelString, theLeft, theBottom, maxWidth, alignment, wrapsBool, controlSize, boldType} waitUntilDone:true
end if
return handlerResult
end create label
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
if NSThread's isMainThread() as boolean then
my createFieldMainThread:{enteredText, placeholder, theLeft, theBottom, theWidth, extraHeight, acceptsTabs}
else
my performSelectorOnMainThread:"createFieldMainThread:" withObject:{enteredText, placeholder, theLeft, theBottom, theWidth, extraHeight, acceptsTabs} waitUntilDone:true
end if
return handlerResult
end create field
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
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
set {theLabel, theTop, newWidth} to create label theLabel left inset theLeft bottom (theTop + 8) max width theWidth aligns left aligned without multiline
return {theField, theLabel, theTop}
end create top labeled field
on create image view posixPath left inset theLeft bottom theBottom view width viewWidth view height viewHeight scale image imageScale : scale down proportionally align image imageAlignment : center aligned
if NSThread's isMainThread() as boolean then
my createImageViewMainThread:{posixPath, theLeft, theBottom, viewWidth, viewHeight, imageScale, imageAlignment}
else
my performSelectorOnMainThread:"createImageViewMainThread:" withObject:{posixPath, theLeft, theBottom, viewWidth, viewHeight, imageScale, imageAlignment} waitUntilDone:true
end if
return handlerResult
end create image view
on buildAccessoryViewMainThread:theArg
set {accViewControls, theLeft, theBottom, theWidth, theTop} to theArg
set my theAccessoryView to current application's NSView's alloc()'s initWithFrame:{{theLeft, theBottom}, {theWidth, theTop - theBottom}}
repeat with aControl in accViewControls
(theAccessoryView's addSubview:aControl)
end repeat
end buildAccessoryViewMainThread:
set theTable to make new table with data {"One", "Two", "Three", "Four", "Five"} with empty selection allowed
modify table theTable ¬
accessory view theAccessoryView
set theAccessoryView to missing value -- to avoid error messages when saving
display table theTable ¬
with extended results
set theState to theField's stringValue()
Nevermind…
→ Script Debugger 8.0.5 (8A61)
→ MacOS 12.6.4
→ Myriad Tables 1.0.12