CheckBox ControlInfo doesnot work inside a mouse event

This is the code that allows someone to drag a trace from a graph and add it to a another graph.
I borrowed this code from utility "Drag and Drop Traces by" "RGerkin" and used it in my own program with certain modifciation and bug fixed.
I added a Checkbox named "Check5" and used it to select whether the "AppendToGraph" is with or without reverse axis.( See the code within two red horizontal dashed line.")

But Somehow this control does not work. always it choose the default unchecked option ( without reverse axis ) although it does not give any wrong message. Is it because this control is within a mouse event that’s why its not working ? or I am missing something.



CheckBox Check5, pos={300,265},size={39,14},title="Reverse Axis",value= 0

Function DragAndDropToggle()
	variable i
	string wins=winlist("*",";","WIN:1")
	dfref df=root:Packages:DragAndDropTraces
 	
 
 	
 	if(!datafolderrefstatus(df))
 		newdatafolder /o root:Packages
		newdatafolder /o root:Packages:DragAndDropTraces
		dfref df=root:Packages:DragAndDropTraces
		string /g df:source,df:dest,df:trace
		variable /g df:lsize	
		for(i=0;i<itemsinlist(wins);i+=1)
			string win=stringfromlist(i,wins)
			setwindow $win hook(DragAndDrop)=DragAndDropHook
		endfor
	else
		killdatafolder df
 		for(i=0;i<itemsinlist(wins);i+=1)
			win=stringfromlist(i,wins)
			setwindow $win hook(DragAndDrop)=$""
		endfor
 	endif
End


Function DragAndDropHook(info)


	struct WMWinHookStruct &info
	
		
	
	
 	dfref df=root:Packages:DragAndDropTraces
 	if(!datafolderrefstatus(df))
		return -1
	endif
	
	string trace_info1=TraceFromPixel(info.mouseLoc.h,info.mouseLoc.v,"")
	getwindow $info.winName psizeDC
	variable mouseH=info.mouseLoc.h, mouseV=info.mouseLoc.v // Convert to variables.  
	if(mouseH>v_right || mouseH<v_left || mouseV<v_top || mouseV>v_bottom)
		nvar /sdfr=df lsize
		svar /sdfr=df trace
		if(strlen(trace) && lsize)
			modifygraph /z lsize($trace)=lsize
		endif
	endif
	switch(info.eventCode)
		case 3: // Mouse down.  
			if(strlen(trace_info1))
				info.cursorCode=1
				info.doSetCursor=1
				string /g df:trace=stringbykey("TRACE",trace_info1), df:source=info.winName
				svar /sdfr=df trace
				string trace_info2=traceinfo(info.winName,trace,0)
				variable /g df:lsize=numberbykey("lsize(x)",trace_info2,"=")
				nvar /sdfr=df lsize
				if(numtype(lsize))
					return -2
				endif
				modifygraph lsize($trace)=min(10,lsize*3)
			endif
			break
		case 5: // Mouse up.  
			nvar /sdfr=df lsize
			svar /sdfr=df trace,source
			if(strlen(trace) && strlen(source) && lsize)
				modifygraph /z/w=$source lsize($trace)=lsize
			endif
			if(!stringmatch(source,info.winName)) // Dragged from another window.  
				wave w1=tracenametowaveref(source,trace)
				wave xWave = XWaveRefFromTrace(source, trace)
				// removefromgraph /z/w=$source $trace
//---------------------------------------------------------------------------------------------------------------				
    Variable Conf5
    ControlInfo Check5
    Conf5= V_value

		
                  if (Conf5)
     appendtograph/R /w=$info.winName w1 vs xWave
                   else
     appendtograph /w=$info.winName w1 vs xWave
         endif
				
//------------------------------------------------------------------------------------------------------------------				
				
				//display w1 vs xWave
			endif
			trace=""
			break
	endswitch
End


Have you checked the value of V_flag after the ControlInfo operation? Acording to command help:

The kind of control is returned in V_flag as a positive or negative integer. A negative value indicates the control is incomplete or otherwise not active. If V_flag is zero, then the named control does not exist.


V_flag = 2 for a checkbox.
I suggest that you probably want to do a ControlInfo/W=panelname Check5 where panelname is the name of the panel where the checkbox resides. Also, you can save yourself the need to create a new variable, so the result is ...

ControlInfo/W=panelname Check5 if (V_value) ... endif

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
Whenever I come accross this, it is usually a result of checking for the control in the wrong panel. If it doesn't exist in the topmost panel, the returned is usually the default value. This is very common when dealing with multiple windows (your two graphs). JJweimer's advice for specifying the panel name usually solves the problem for me.
Thanks to J.J.Weimer, Proland and Jtigor.
Indeed Panel name was the problem and as Weimer suggested ControlInfo/W=panelname solved the problem
Thank you so much to all of you