In those cases where you are using PopMenus on control panels, you may wish to avoid having the popmenu procedure execute after a mouse up in the case where the selected choice has not changed. This code snippet compares the menu choice with the string stored in the userData to cause such a behavior.
// check whether a popup has been changed
// uses userdata
// returns 1 when changed or 0 when not
Static Function X_PopHasChanged(STRUCT WMPopupAction &pa)
variable vv = abs(cmpstr(pa.popStr,pa.userdata))
if (vv != 0)
pa.userdata = pa.popstr
endif
return vv
end
Here is an example use.
Static Function Do_PopupMenuAction(STRUCT WMPopupAction &pa) : PopupMenuControl
switch( pa.eventCode )
case 2: // mouse up
if (!ModuleName#X_PopHasChanged(pa))
return 0
endif
switch(pa.popNum)
case 1: // ...
Note also the use of STATIC for the function call and ModuleName# for the preface to the X_PopHasChanged(...) function call. Use these options as needed especially to avoid clashes with other packages that may use the same (static) function name in their own Module (or Independent Module).
UPDATE: The newest version will not give a warning when checking with ipt lint.
Forum
Support
Gallery
Learn More
Learn More
Learn More