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
proc=is the name of the action procedure, without parentheses.- The action function takes a
STRUCT WMButtonActionand returns a number. eventCode == 2is the mouse-up, which is the click you want.
Keywords and builtins used here
ButtonEndFunctionPrintfSTRUCTendififprocreturn
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.
Step 2 of 3 in A panel, step 2 of 18 in Panels & GUI.