New graph window hook?

Following the advice from this thread on managing right-clicks (http://www.igorexchange.com/node/4218), I'm implementing a user-defined contextual menu for graphs; however, it would be convenient to apply the contextual menu to all created graphs instead of having to apply it each time with the following code:

SetWindow kwTopWin hook=GraphContextual, hookevents=1


Is there an igor event hook function or other method of doing this? I can't see any function in the user-defined hooks list that could serve this purpose.
No, you have to apply it to each graph individually.

You can write a loop using WinName to loop through all graphs and apply the hook.

You should choose a distinctive name, such as TKGraphHook, for your hook to avoid clashing with other people's packages. Alternatively you can put your hook in a regular or independent module.

DisplayHelpTopic "Regular Modules"
DisplayHelpTopic "Independent Modules"

Thanks. Yeah, I have a unique prefix tag for most of my functions (that code above was just an example), so it shouldn't conflict. I'll look at cycling through windows and otherwise implementing it into my code on a per-graph basis.
I think you could use the AfterWindowCreatedHook function. See the help:

DisplayHelpTopic "User-Defined Hook Functions"

Best of luck. It can be tricky to make these hook functions work correctly all the time.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
johnweeks wrote:
I think you could use the AfterWindowCreatedHook function. See the help:

DisplayHelpTopic "User-Defined Hook Functions"

Best of luck. It can be tricky to make these hook functions work correctly all the time.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com


THANK YOU! That works perfectly so far. I'll keep an eye out for any quirks, but it appears to be working great. I must have overlooked this option when perusing the hook options.