function Func_TableHook(STRUCT WMWinHookStruct &s, string &parentWindowName) Variable hookResult = 0 // 0 if we do not handle event, 1 if we handle it. switch(s.eventCode) case 3: // mouse down Func_WorkPosTableBoundsCheck () break case 11: // This code activates as user completes their edit of a cell switch (s.keyCode) case 0x03: // Enter case 0x0d: // return case 0x1c: // left arrow case 0x1d: // right arrow case 0x1e: // up arrow case 0x1f: // down arrow Func_WorkPosTableBoundsCheck () break default: break endswitch break case 24: // This code activates when user leaves cell by clicking mouse away from cell Func_WorkPosTableBoundsCheck () break //case 25: // tableEntryCancelled - unused at the moment // break default: break endswitch return hookResult end function Func_WorkPosTableBoundsCheck() WAVE workPos GetSelection table, demoPanel#tSeqPos, 0x07 // Determine which cell(s) is(are) selected if (V_flag==0) // nothing selected (apparently) return 0 endif make /O /n=4 posWave variable minOK, maxOK, proposedNewVal int thisRow, thisCol for (thisCol=V_StartCol; thisCol<=V_endCol; thisCol++) if (thisCol==0) minOK = 0 maxOK = 9 elseif (thisCol==1) minOK = 10 maxOK = 99 elseif (thisCol==2) minOK = 100 maxOK = 999 elseif (thisCol==3) minOK = 1000 maxOK = 9999 else printf "Func_WorkPosTableBoundsCheck() invalid col:%d\n", thisCol endif for (thisRow=V_StartRow; thisRow<=V_endRow; thisRow++) // Refinement in IgorPro 8.02 enables us to read directly the string contained in the table's cell, // independent of the value of the corresponding point in the wave. ModifyTable/W=demoPanel#tSeqPos selection=(thisRow,thisCol,thisRow,thisCol,thisRow,thisCol), entryMode=0 // query proposedNewVal = str2num (S_Value) if (numType (proposedNewVal) == 0) // ... we extracted a numeric value proposedNewVal = limit (proposedNewVal, minOK, maxOK) else // ... something non numeric (ex. NaN, INF, etc.); retain prev value <=> this cell proposedNewVal = workPos[thisRow][thisCol] endif workPos[thisRow][thisCol] = proposedNewVal // install filtered value in wave endfor endfor end