Built-in Graph Pop-Up Menu

gregorK
Posts: 82
Joined: 2010-03-19
Location: Slovenia

Hi!

Is there any way to get the information which built-in Graph Pop-Up Menu Item was selected by the user?
I can catch a modified event with a window hook (I am interested in catching trace append/remove, color change events), but I have no idea how to understand which of the menu items was chosen since it is a built-in menu ... (with a user menu one can call GetLastUserMenuInfo) ... I am on IGOR 6.37

Thanks for any help!

Gregor

--
Gregor K
ALOISA Beamline
Elettra Synchrotron


JimProuty's picture
Posts: 619
Joined: 2007-07-19
Location: United States

See
DisplayHelpTopic "IgorMenuHook"

Pay close attention to the value of the isSelection parameter.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.


gregorK
Posts: 82
Joined: 2010-03-19
Location: Slovenia

Thanks for the hint!

Gregor

--
Gregor K
ALOISA Beamline
Elettra Synchrotron


gregorK
Posts: 82
Joined: 2010-03-19
Location: Slovenia

Hi Jim!

Following your reply I have just checked the IgorMenuHook function, but it seems that it does not get triggered when using built-in Pop-Up Menus (eg. Right-Click on a Graph), at least not on my version of Igor (6.37). Is this true or am I doing something wrong?

Is there any other way to trigger on a user selected menu item of a built-in Pop-up Menu?

Thanks again for your help.

--
Gregor K
ALOISA Beamline
Elettra Synchrotron


JimProuty's picture
Posts: 619
Joined: 2007-07-19
Location: United States

gregorK wrote:
Hi Jim!

Following your reply I have just checked the IgorMenuHook function, but it seems that it does not get triggered when using built-in Pop-Up Menus (eg. Right-Click on a Graph), at least not on my version of Igor (6.37). Is this true or am I doing something wrong?

Is there any other way to trigger on a user selected menu item of a built-in Pop-up Menu?

I skipped over the bit about you using the popup menus instead of the menubar menus.

The feature you want isn't implemented in Igor (any version).

The idea of the menu hook is to give the programmer an opportunity to modify and respond to menubar menu items.

Relatively few people have used the feature, and so it was never extended to contextual menus such as are in the graph.

Even the existing hook function really isn't designed to capture whether the user completed using the task that the menu item implements.

For example, the hook can tell you that the user selected the Graph->Modify Trace Appearance dialog, but doesn't tell you whether the dialog was cancelled or not.

I think you'll need to approach your problem from a different direction.

Why not use the graph's "modified" event in your own window function and compare the trace characteristics before the menu pops up (you can catch that event; see the examples) with the characteristics when the modified event comes in?

--Jim Prouty
Software Engineer, WaveMetrics, Inc.


JimProuty's picture
Posts: 619
Joined: 2007-07-19
Location: United States

Here's a proof-of-concept. What you save before is up to you; I just save the window's entire recreation macro into a global string.

#pragma rtGlobals=3		// Use modern global access method and strict wave access.
 
Macro DemoHandlingGraphChanges()
 
	Make/O data1=x
	Display/K=1 data1
 
	setwindow kwTopWin hook(changeHook)= BeforeAndAfterHook
End
 
 
 
Function BeforeAndAfterHook(s)
	STRUCT WMWinHookStruct &s
 
	strswitch(s.eventName)
		case "modified":	
			HandleGraphModified()
			break
	endswitch
 
	return 0
End
 
Menu "GraphPopup", dynamic
	RememberGraphSettings(), /Q, Beep
End
 
Function/S RememberGraphSettings()
 
	String/G root:recreationBefore = WinRecreation("",4)
	return "" // menu item disappears
End
 
Function HandleGraphModified()
	SVAR/Z before= root:recreationBefore
	String after = WinRecreation("",4)
 
	if( CmpStr(before,after) != 0 )
		// To Do:
		// Check for differences, and do what' needed
		Print "--- before-- "
		Print before
		Print "--- after-- "
		Print after
	endif
End

--Jim Prouty
Software Engineer, WaveMetrics, Inc.


gregorK
Posts: 82
Joined: 2010-03-19
Location: Slovenia

Great! Jim thank you very much. Its a nice idea saving the graph recreation with the help of a hidden menu item.

--
Gregor K
ALOISA Beamline
Elettra Synchrotron


Back to top