Group Abstract Group Abstract

Message Boards Message Boards

Make an index with a popup menu?

Posted 9 years ago
POSTED BY: W Mora
2 Replies

You can do this more simply with:

    ActionMenu["Choose a File...", {
    "nb1.nb" :> NotebookOpen[FileNameJoin[{NotebookDirectory[], "nb1.nb"}]], 
    "nb2.nb" :> NotebookOpen[FileNameJoin[{NotebookDirectory[], "nb2.nb"}]], 
    "nb3.nb" :> NotebookOpen[FileNameJoin[{NotebookDirectory[], "nb3.nb"}]]}]

or if you want to dynamically create the actions:

Module[{nblist = {"nb1.nb", "nb2.nb", "nb3.nb"}}, 
 ActionMenu["Choose a File...", 
  MapThread[
   RuleDelayed, {nblist, 
    Unevaluated[
       NotebookOpen[FileNameJoin[{NotebookDirectory[], #}]]] & /@ 
     nblist}] ]]

The Action Menu list is created by joining the file path to each filename in the list, nblist. The NotebookOpen command must be delayed (with Unevaluated) or it tries to act immediately. The MapThread[RuleDelayed... creates the list of rules so it looks like the first version.

Some other interface wizards on this forum may be able to make this even simpler, but that is my first take...

Regards

POSTED BY: Neil Singer
Posted 9 years ago

Thanks, that is that I was looking for.

POSTED BY: W Mora
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard