PopUpMenu returns wrong String by "ControlInfo"
PeterR
my Panel contains a PopUpMenu:
PopupMenu popup0,pos={34,508},size={195,24},bodyWidth=195
PopupMenu popup0,mode=1,proc=popmenuproc,value= #"\"Empty;Marker;Standard 1;Standard 2;Standard 3;Standard 4;Unknown\""
PopupMenu popup0,mode=1,proc=popmenuproc,value= #"\"Empty;Marker;Standard 1;Standard 2;Standard 3;Standard 4;Unknown\""
When I to decide how to go on in the procedure, the
Function TabProc(tab0,tabnum) : TabControl
String tab0
Variable tabNum
if (tabnum == 0)
GroupBox group0 disable = 0
GroupBox group7 disable = 0
PopUpMenu popup0 disable = 0
ControlInfo /W=GelQuant popup0 --> HERE the program always returns "Empty", no matter what
strswitch(S_Value)
case "Empty":
SetVariable setvar2 disable = 1
CheckBox check4 disable = 1
HideRightBox_Lane1()
break
case "Marker":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 2
HideRightBox_Lane1()
break
case "Standard 1":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 2
HideRightBox_Lane1()
break
case "Standard 2":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 2
HideRightBox_Lane1()
break
case "Standard 3":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 2
HideRightBox_Lane1()
break
case "Standard 4":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 2
HideRightBox_Lane1()
break
case "Unknown":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 0
ControlInfo /W = GelQuant check4
If(V_Value == 1)
ShowRightBox_Lane1()
else
HideRightBox_Lane1()
endif
break
return -1 // wrong string transferred, abort
endswitch
String tab0
Variable tabNum
if (tabnum == 0)
GroupBox group0 disable = 0
GroupBox group7 disable = 0
PopUpMenu popup0 disable = 0
ControlInfo /W=GelQuant popup0 --> HERE the program always returns "Empty", no matter what
strswitch(S_Value)
case "Empty":
SetVariable setvar2 disable = 1
CheckBox check4 disable = 1
HideRightBox_Lane1()
break
case "Marker":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 2
HideRightBox_Lane1()
break
case "Standard 1":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 2
HideRightBox_Lane1()
break
case "Standard 2":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 2
HideRightBox_Lane1()
break
case "Standard 3":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 2
HideRightBox_Lane1()
break
case "Standard 4":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 2
HideRightBox_Lane1()
break
case "Unknown":
SetVariable setvar2 disable = 0
CheckBox check4 disable = 0
ControlInfo /W = GelQuant check4
If(V_Value == 1)
ShowRightBox_Lane1()
else
HideRightBox_Lane1()
endif
break
return -1 // wrong string transferred, abort
endswitch
The Problem is now, whenever the procedure is evoked, it returns "Empty" as S_Value, which hinders the procedure from functioning correctly (the switch is basically completely ignored)- I'm desperate, what can I do about it?
Any help is highly appreciated :)
Regards,
Peter
NewPanel
PopupMenu popup0,mode=1,proc=popmenuproc,value= #"\"Empty;Marker;Standard 1;Standard 2;Standard 3;Standard 4;Unknown\""
End
Function PopMenuProc(pa) : PopupMenuControl
STRUCT WMPopupAction &pa
switch( pa.eventCode )
case 2: // mouse up
Variable popNum = pa.popNum
String popStr = pa.popStr
print popStr
break
case -1: // control being killed
break
endswitch
return 0
End
From looking at your code you are using a TabControl to handle different tabs.
Maybe the popupmenu has not been rebuilt yet?
You can also check V_Value of ControlInfo, maybe that gives some more explanatory status code.
August 1, 2014 at 12:06 pm - Permalink
The strange thing is, that the choice I make is remembered by the PopUpMenu and also correctly displayed, but whenever I want to read out the value, it always returns 1 for V_Value.... :/
August 1, 2014 at 12:13 pm - Permalink
August 1, 2014 at 01:41 pm - Permalink
August 1, 2014 at 08:52 pm - Permalink
August 1, 2014 at 08:59 pm - Permalink
This kind of thing has been working for ever so long that I'm sure there's something non-obvious that is causing your problems.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
August 1, 2014 at 09:12 pm - Permalink
STRUCT WMTabControlAction &tcstruct
variable tabNum = tcstruct.tab, rtn = 0, sh = 0
switch(tabNum)
case 0:
GroupBox group0 win=GelQuant, disable = 0
GroupBox group7 win=GelQuant, disable = 0
PopUpMenu popup0 win=GelQuant, disable = 0
break
endswitch
ControlInfo /W=GelQuant popup0
strswitch(S_Value)
case "Empty":
SetVariable setvar2 win=GelQuant, disable = 1
CheckBox check4 win=GelQuant disable = 1
break
case "Marker":
SetVariable setvar2 win=GelQuant, disable = 0
CheckBox check4 win=GelQuant, disable = 2
break
case "Standard 1":
SetVariable setvar2 win=GelQuant, disable = 0
CheckBox check4 win=GelQuant, disable = 2
break
case "Standard 2":
SetVariable setvar2 win=GelQuant, disable = 0
CheckBox check4 win=GelQuant, disable = 2
break
case "Standard 3":
SetVariable setvar2 win=GelQuant, disable = 0
CheckBox check4 win=GelQuant, disable = 2
break
case "Standard 4":
SetVariable setvar2 win=GelQuant, disable = 0
CheckBox check4 win=GelQuant, disable = 2
break
case "Unknown":
SetVariable setvar2 win=GelQuant, disable = 0
CheckBox check4 win=GelQuant, disable = 0
ControlInfo /W = GelQuant check4
sh = V_Value
rtn = -1
break
endswitch
ShowHideRightBox_Lane1(sh)
return rtn
end
// show a different way here to collapse code for RightBox_Lane1() to one place
Function ShowHideRightBox_Lane1(sh)
variable sh
switch(sh)
case 0:
HideRightBox_Lane1()
break
case 1:
ShowRightBox_Lane1()
break
endswitch
return 0
end
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
August 2, 2014 at 06:37 am - Permalink
Thanks in advance for your support!
August 2, 2014 at 07:13 am - Permalink
August 2, 2014 at 07:15 am - Permalink
Since you did not describe how to reproduce the problem in your simplified experiment, I am guessing a bit here...
I first noticed that if you execute panel() and then select tab 2 and then tab 1, Igor gives an error about use of a NULL string variable. The line that caused that error is the strswitch call in function TabProc() (line 49). This error happens because when you call ControlInfo, you use the /W flag, passing a window name that does not exist. If I change that line to
ControlInfo /W=panel popup0
, and then test again, I get no Igor error and changing the selected value in the popup box of tab 1 causes other controls in that group box to be hidden/disabled in a way that seems appropriate to me.Are you sure that you're using the latest version of Igor (6.34A)?
If what I've described isn't the problem you're having, please tell us exactly how to reproduce the problem.
August 2, 2014 at 07:32 am - Permalink
Now the procedure works as it should! Thanks again!
August 2, 2014 at 07:50 am - Permalink