typestar

Popup menus in Igor Pro

A popup's list can be a literal string or an expression evaluated when it opens.

Function AddPopup()
    PopupMenu waveSel, pos={16, 132}, size={220, 20}, title="Wave"
    PopupMenu waveSel, value=#"WaveList(\"*\", \";\", \"\")"
    PopupMenu waveSel, mode=1, proc=WavePicked
End

Function WavePicked(STRUCT WMPopupAction &pa) : PopupMenuControl
    if (pa.eventCode != 2)
        return 0
    endif

    WAVE/Z chosen = $pa.popStr
    if (WaveExists(chosen))
        Printf "%s: %d points\r", pa.popStr, numpnts(chosen)
    endif
    return 0
End

How it works

  1. value= starting with # is a string expression, re-read on each open.
  2. mode= is the one-based selection; popvalue= sets it by text.
  3. The action gets popStr and popNum.

Keywords and builtins used here

The run, in numbers

Lines
17
Characters to type
414
Tokens
94
Three-star pace
85 tpm

At the three-star pace of 85 tokens a minute, this run takes about 66 seconds.

Type this snippet

Step 3 of 5 in Values a user sets, step 6 of 18 in Panels & GUI.

← Previous Next →