typestar

Buttons in Igor Pro

A button names the function it calls, and that function receives a structure.

Function AddButtons()
    Button runBtn, pos={16, 44}, size={90, 24}, title="Run", proc=RunClicked
    Button clearBtn, pos={116, 44}, size={90, 24}, title="Clear"
    Button clearBtn, proc=RunClicked, fColor=(48000, 20000, 20000)
End

Function RunClicked(STRUCT WMButtonAction &ba) : ButtonControl
    if (ba.eventCode != 2)
        return 0
    endif

    Printf "%s pressed in %s\r", ba.ctrlName, ba.win
    return 0
End

How it works

  1. proc= is the name of the action procedure, without parentheses.
  2. The action function takes a STRUCT WMButtonAction and returns a number.
  3. eventCode == 2 is the mouse-up, which is the click you want.

Keywords and builtins used here

The run, in numbers

Lines
14
Characters to type
387
Tokens
103
Three-star pace
80 tpm

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

Type this snippet

Step 2 of 3 in A panel, step 2 of 18 in Panels & GUI.

← Previous Next →

Buttons in other languages