« Video playback with m… | Home | MBS FileMaker Plugin,… »

Tip of the day: Build contextual menu in FileMaker from a table

As you see here, we build a menu in FileMaker. We go to a separate layout with our menu entries table. There we loop from first to last record and look if the group matches the one we got in script parameter. Than we add this menu entry to the menu for calling the script in the table. This way the user can edit menu by editing the table.


# go to layout with menu entries

Go to Layout [ “REP” (REP Reports) ]

# this script can be called with various groups

Set Variable [ $type ; Value: Get(ScriptParameter) ] 

# make a new menu

Set Variable [ $menu ; Value: MBS( "Menu.CreateMenu") ] 

# loop over records

Go to Record/Request/Page [ First ]


# if group matches

If [ REP Reports::Group = $type ] 

# add new menu item with title from table

Set Variable [ $item ; Value: MBS( "MenuItem.CreateMenuItem"; REP::LabelReport) ] 

# define which script to call if menu item is selected

Set Variable [ $r ; Value: MBS( "MenuItem.SetScriptAction"; $item; Get(FileName); REP::Script ) ] 

# add item to menu

Set Variable [ $r ; Value: MBS( "Menu.AddItem"; $menu; $item ) ] 

End If

# next record?

Go to Record/Request/Page [ Next ; Exit after last ] 

End Loop

# switch layout back

Go to Layout [ original layout ]

# Show menu

Set Variable [ $r ; Value: MBS( "Menu.PopUp"; $menu; "mouse") ] 

# Cleanup memory

Set Variable [ $r ; Value: MBS( "Menu.Release"; $menu) ] 

On the right a sample menu made by the plugin, so you can see what is possible.
11 09 15 - 10:51
No comments

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.