typestar

Sliders in Igor Pro

A slider is a SetVariable you can drag, and it reports continuously unless told not to.

Function AddSlider()
    Slider widthSlider, pos={16, 44}, size={200, 50}
    Slider widthSlider, limits={1, 51, 2}, value=5, live=0
    Slider widthSlider, vert=0, ticks=5, proc=WidthMoved
End

Function WidthMoved(STRUCT WMSliderAction &sa) : SliderControl
    if ((sa.eventCode & 1) == 0)
        return 0
    endif

    NVAR window = root:Settings:gWindow
    window = round(sa.curval)
    Printf "window %d\r", window
    return 0
End

How it works

  1. limits={low, high, increment} and variable= are the essentials.
  2. live=0 waits for the mouse to come up before reporting.
  3. The action's curval is the value, and eventCode says why it fired.

Keywords and builtins used here

The run, in numbers

Lines
16
Characters to type
394
Tokens
105
Three-star pace
85 tpm

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

Type this snippet

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

← Previous Next →