Window hooks in Igor Pro
A hook function sees what happens to the window itself, not to one control.
Function AttachHook()
SetWindow AnalysisPanel, hook(cleanup)=PanelHook
End
Function PanelHook(STRUCT WMWinHookStruct &s)
strswitch (s.eventName)
case "kill":
KillDataFolder/Z root:Settings
break
case "mousedown":
Printf "click at %d, %d\r", s.mouseLoc.h, s.mouseLoc.v
break
endswitch
return 0
End
How it works
SetWindow hook(name)=attaches it; the name lets you remove it.- The structure carries
eventName, the window, and the mouse position. - Returning zero lets Igor handle the event as usual.
Keywords and builtins used here
EndFunctionKillDataFolderPrintfSTRUCTSetWindowbreakcaseendswitchreturnstrswitch
The run, in numbers
- Lines
- 16
- Characters to type
- 298
- Tokens
- 59
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 39 seconds.
Step 3 of 5 in Wiring it up, step 15 of 18 in Panels & GUI.