Following up on my own question, here's what I've figured out so far:
1) Have the awake from nib handler store a reference to the action's
content view (which in this example is named "contentView" in the
AppleScript pane of the IB Inspector):
property gContentView: missing value
on awake from nib theObject
if (name of theObject) is "contentView" then
-- when the content view is loaded from the nib,
remember its reference
set gContentView to theObject
end if
end awake from nib
2) To put up a panel, create a separate nib containing the panel
(which has a window title of "MyPanel" in this example). Use the
content view to get the action reference, the action reference to get
the action bundle, and the bundle to load the nib. Then the panel
can be referenced by name (assuming there's only one window with the
window title in question). Store the window reference in a property
so we don't load the nib (creating the window) more than once:
property gMyPanel: missing value
on clicked theObject
if name of theObject is "displayPanelButton" then
if gMyPanel is missing value then
set actionViewReference to the super view of
gContentView
set theAction to (call method "action" of
actionViewReference)
load nib "mypanelnib" in bundle (call method
"bundle" of theAction)
set gMyPanel to window "MyPanel2"
end if
set automatorWindow to window of gContentView
display gMyPanel attached to automatorWindow
end if
end clicked
3) The problem with this approach is that I don't see a good way to
get the results out of the panel. In AppleScript Studio you would
have a "panel ended" handler on the window in question, but in this
case we're attaching the panel to the Automator window, so that's
out.
Another option is saving whatever the user entered in the "clicked"
handler for the panel's OK button (for example). I tried connecting
the panel OK button to the clicked handler in my main script but got
-1708 errors whenever I clicked the button. Moving the handler to a
different script file fixed the problem, but created a new one:
getting the result information from the auxiliary script back to the
main script.
What's the recommended way to pass information between scripts? The
AppleScript Studio documentation recommends using user defaults, but
that seems like a bad idea for an Automator action (I assume the
settings would end up in the Automator app's defaults file).
I've thought of one very ugly way to do it, but I'd be interested in
hearing what's recommended.
Thanks,
--
Jim Matthews
Fetch Softworks
http://fetchsoftworks.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Automator-dev mailing list (
Automator-dev@list...)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/automator-dev/subscriber%40opensubscriber.com
This email sent to
subscriber@open...
opensubscriber is not affiliated with the authors of this message nor responsible for its content.