Darn, I hate when the answer to my confused question was in the
Reference stack all along. I was looking for something to do with the
menuPick syntax, when what I was missing was just the correct "send"
syntax.
To recap, I created an option button (called "recentStacks") that I
stuck on the Home card, which keeps a list of the stacks I work on so
I can just open them from the button instead of going through the
File menu or whatever. At the end of the list I inserted a divider
line and then an Other... item which just accesses the open file
dialog box.
That worked just fine. I added the following to the Home stack script
to get the recent stack names to add themselves to the option button
automagically:
on closeStack
if the short name of the topStack is not among \
the lines of btn "recentStacks" of cd 1 of stack "Home" then
put the short name of the topStack & return before line \
((the num of lines of btn "recentStacks" of cd 1 of stack "Home") - 1) \
of btn "recentStacks" of cd 1 of stack "Home"
end if
end closeStack
The script of the option button is mostly stolen from somewhere else
in the provided MetaCard stacks, I think it was probably just from
the MetaCard File, Open menu item itself:
on menuPick which
if which is not "Other..." then
open stack which
else
local filterstring
if the systemFileSelector then
switch the platform
case "Win32"
put "MetaCard Stacks" & cr & "*.mc" & cr & "All Files" & cr & "*.*"
\into filterstring
break
case "MacOS"
put "MSTKSTAK" into filterstring
break
default
put "*.mc" into filterstring
end switch
else put "*.mc" into filterstring
answer file "Open stack:" with filter filterstring
if it is not empty then
set the cursor to watch
topLevel it
end if
end if
end menuPick
This worked fine, too. The next thing I wanted to do was to make the
option button act like a default button, so if I pressed Return/Enter
it would open the stack whose name was currently showing on the
option button.
The solution was the following in the Home card script:
on returnKey
get the label of btn "recentStacks"
send "menuPick it" to btn "recentStacks"
end returnKey
The reason I hadn't been able to make it work before was just because
I hadn't figured out that I had to put the "menuPick it" bit in
quotes. Arrghh!
Anyway, thanks to everyone for helping.
Regards,
David
--
David Cramer, Process Innovation Evangelist 87-1313 Border Street
PBSC Computer Training Centres (an IBM company) Winnipeg MB R3H 0X4
Corporate Office Research & Development Canada
This is the MetaCard mailing list.
Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm