Popupmenu enhancements for very many entries


The popup menus in Igor are currently not usable for more than > 50 entries.


make/T/N=256/O data = num2char(97 + mod(p, 26)) + "_" + num2str(p)
string/G str = Textwavetolist(data, ";")
PopupMenu pop, value=str


  • User has to do too much scrolling for selecting an entry.
  • When selecting an entry from very far off from the currently selected entry there is also a lot of scrolling involved too.
  • Unresolved issues in multi monitor setups where no entries are shown at all 

Proposed solution

Provide a mechanism for creating subgroups for the popup menus like in 1.


PopupMenu subMenu(SubMenuName)="a_.*", subMenu(...)=...

Inner working

All popupmenu list items matching the regular expression would be collected and moved into a submenu named SubMenuName. The order of giving the keywords determines the order of collection for multiple submenus. No entry can be in more than one submenu. The position of the submenu can be set by adding an entry named SubMenuName into the item list. There is no resorting done so the order of the entries is completely controllable by the user.

GUI control procedure

The submenus are transparent for the GUI procedure this means the list indizes passed into it are the linear indizes without using submenus. There is no event send when selecting a submenu entry.

Advanced usage

Recursion can be achieved by adding entries like SubMenuA#SubMenuB. There SubMenuB would be a submenu in SubMenuA. The items for SubMenuB would be collected just from the subset of items of SubMenuA.

Alternative ways of specifying the list

There are cases where a regular expression is not the right choice. For these cases the user can specify a semicolon separated list of items for each submenu or one could invent new Special Characters in Menu Item Strings specifiers for denoting a submenu name and to which submenu an item belongs.


Can you use PopupContextualMenu/N=nameOfMenuDefinition, instead?

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Thanks Jim for the hint!

Looks promising

Function YourFunction()
    PopupContextualMenu/ASYN=Callback "first;second;third;"
    // (YourFunction continues...)

// Routine called when/if popup menu item is selected. selectedItem=1 is the first item.
Function Callback(String list, String selectedText, Variable selectedItem)
    Print "Callback: ", list, selectedText, selectedItem

Function Setup()

    string/G list = ""
    variable i

    make/T/N=26/O data = num2char(97 + mod(p, 26)) + "_" + num2str(p)

    for(i = 0; i < 26; i += 1)
        if(i == 25)
            list = AddListItem("submenuA ➨", list, ";", Inf)
            list = AddListItem(data[i], list, ";", Inf)
    Killwindow/Z panel0
    Popupmenu pop, value=list, proc=PopMenuProc,  bodyWidth=105

Function PopMenuProc(pa) : PopupMenuControl
    STRUCT WMPopupAction &pa

        case 2: // mouse up
            Variable popNum = pa.popNum
            String popStr = pa.popStr
            if(!cmpstr(popStr, "submenuA ➨"))
            print pa.eventCode 

    return 0

but is quite unintuitive as the user has to click the submenu and then also the main popup menu is hidden. This is contrary to the common way a submenu works (try out File->Recent Experiments).

Has this (or any other scheme for adding sub-menus to PopupMenus) been implemented in Igor 8?