Contextual Menus

Playing around with contextual menus… Wondering if there’s a way to customize those menus for specified fields only. By default, Panorama offers different contextual menu options depending on data type, but custom menus created with windowbar stmt seem to be limited to the same menu choices for all fields. Seems like there might be a way to differentiate by field? Or is there perhaps another way to customize only a subset of fields? Thanks!

You should be able to do whatever you want. You simply would need to create a formula that generated different menus depending on the contents of info(“fieldname”). You could use the ?( function for this, but probably switch( would be even better in most instances. For a mailing list database, this could look something like this:

windowmenubar "",
    menu("Context Menu")+
        switch(info("fieldname"),
            "First",
                menuitem("...")+
                menuitem("..."),
            "Last",
                menuitem("...")+
                menuitem("..."),
            "Address",
                menuitem("...")+
                menuitem("..."),
            "Zip",
                menuitem("...")+
                menuitem("..."),
            // default menu items for any field not mentioned
            menuitem("Show Field Properties")+
            menuitem("Add Field")+
            menuitem("Insert Field")+
            menuitem("Delete Field")
        ),
    "COLUMN_CONTEXTMENU"

The example above is for the column context menu, but you could do the same thing for clicking on data cells.

Thanks, Jim.
FWIW, I’m working on a way to classify daily expenditures under a hierarchical tree-type structure, wherein each entry might start out as either “Personal” or “Business”. From there, it might fall down one or two more predetermined classifications before a detailed description is listed (or not ;). Setting aside a few Pan fields in the Datasheet, with contextual menus/submenus, seems like a handy way to do this. Your explanation has launched me on my way, as well as presented a Plethora of Panorama Possibilities/Potholes to be worked through (as usual ;). Thanks!

1 Like