#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access #pragma DefaultTab={3,20,4} // Set default tab width in Igor Pro 9 and later menu "Procedure" submenu "Insert control function" "Popup;SetVariable;CheckBox;Button;Listbox;TabControl;Slider;CustomControl;", /Q, InsertControlActionCode() end end function /S InsertControlActionCode() GetLastUserMenuInfo string strSav = GetScrapText() string strFunc = "" sprintf strFunc, "function %sProc(STRUCT WM%sAction &s) : %sControl\r%s\t\r\treturn 0\rend", s_value, s_value, s_value, actionStructHelp(s_value) strFunc = ReplaceString("PopupControl",strFunc, "PopupMenuControl") PutScrapText strFunc DoIgorMenu "Edit" "Paste" PutScrapText strSav end static function/S actionStructHelp(string which) string comment = "\t// WM"+which+"Action eventCode info:\r" if (!StringMatch(which,"CustomControl")) comment += "\t// -3\tControl received keyboard focus\r" comment += "\t// -2\tControl lost keyboard focus\r" comment += "\t// -1\tControl being killed\r" endif StrSwitch (which) case "Popup": comment += "\t// 2\tMouse up\r" comment += "\t// 3\tHovering\r" break case "SetVariable": comment += "\t// 1\tMouse up\r" comment += "\t// 2\tEnter key\r" comment += "\t// 3\tLive update\r" comment += "\t// 4\tMouse scroll wheel up\r" comment += "\t// 5\tMouse scroll wheel down\r" comment += "\t// 6\tValue changed by dependency update\r" comment += "\t// 7\tBegin edit\r" comment += "\t// 8\tEnd edit\r" comment += "\t// 9\tMouse down\r" break case "CheckBox": comment += "\t// 2\tMouse up, checkbox toggled\r" break case "Button": comment += "\t// 1\tMouse down\r" comment += "\t// 2\tMouse up\r" comment += "\t// 3\tMouse up outside control\r" comment += "\t// 4\tMouse moved\r" comment += "\t// 5\tMouse enter\r" comment += "\t// 6\tMouse leave\r" comment += "\t// 7\tMouse dragged while outside the control\r" break case "Listbox": comment += "\t// 1\tMouse down\r" comment += "\t// 2\tMouse up\r" comment += "\t// 3\tDouble click\r" comment += "\t// 4\tCell selection (mouse or arrow keys)\r" comment += "\t// 5\tCell selection plus Shift key\r" comment += "\t// 6\tBegin edit\r" comment += "\t// 7\tEnd edit\r" comment += "\t// 8\tVertical scroll - See Scroll Event Warnings under ListBox\r" comment += "\t// 9\tHorizontal scroll by user or by the hScroll=h keyword\r" comment += "\t// 10\tTop row set by row=r or first column set by col=c keywords\r" comment += "\t// 11\tColumn divider resized\r" comment += "\t// 12\tKeystroke, character code is place in row field- See Note on Keystroke Event under ListBox\r" comment += "\t// 13\tCheckbox was clicked. This event is sent after selWave is updated.\r" break case "TabControl": comment += "\t// 2\tMouse up\r" break case "Slider": comment += "\t// 1\tValue set\r" comment += "\t// 2\tMouse down\r" comment += "\t// 4\tMouse up\r" comment += "\t// 8\tMouse moved or arrow key moved the slider\r" comment += "\t// 16\tRepeat timer fired (see Repeating Sliders)\r" break case "CustomControl": comment += "\t// kCCE_mousedown = 1\tMouse down in control.\r" comment += "\t// kCCE_mouseup = 2\tMouse up in control.\r" comment += "\t// kCCE_mouseup_out = 3\tMouse up outside control.\r" comment += "\t// kCCE_mousemoved = 4\tMouse moved (only when mouse is over control).\r" comment += "\t// kCCE_enter = 5\tMouse entered control.\r" comment += "\t// kCCE_leave = 6\tMouse left control.\r" comment += "\t// kCCE_mouseDraggedOutside = 7\tMouse moved while it was outside the control (mouse pressed inside and dragged outside).\r" comment += "\t// kCCE_draw = 10\tTime to draw custom content.\r" comment += "\t// kCCE_mode = 11\tSent when executing CustomControl name, mode=m.\r" comment += "\t// kCCE_frame = 12\tSent before drawing a subframe of a custom picture.\r" comment += "\t// kCCE_dispose = 13\tSent as the control is killed.\r" comment += "\t// kCCE_modernize = 14\tSent when dependency (variable or wave set by value=varName) or draw event fires.\r" comment += "\t// kCCE_tab = 15\tSent when user tabs into the control. If you want keystrokes (kCCE_char), then set needAction.\r" comment += "\t// kCCE_char = 16\tSent on keyboard events (keyboard character => kbChar and modifiers bit field => kbMods). Sets needAction if key event was used and requires a redraw.\r" comment += "\t// kCCE_drawOSBM = 17\tCalled after drawing pict from picture parameter into an offscreen bitmap. You can draw custom content here.\r" comment += "\t// kCCE_idle = 18\tIdle event typically used to blink insertion points etc. Set needAction to force the control to redraw. Sent only when host window is on top.\r" break EndSwitch comment += "\t// eventMod bits: 0 = mouse down, 1 = shift, 2 = option | alt, 3 = command | ctrl, 4 = contextual click\r" return comment end