Built-in Graph Pop-Up Menu

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
See
DisplayHelpTopic "IgorMenuHook"

Pay close attention to the value of the isSelection parameter.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Thanks for the hint!

Gregor

--
Gregor K
ALOISA Beamline
Elettra Synchrotron
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
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.
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.
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

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

Add this request to the wish list for relatively few people + 1. I would like to be able to be able to override the context menu on graph windows to the fullest extent so that I can build my own list of context options.

Alternatively, if easier at least for the moment, I wish that I could put my choices as the FIRST set of items in the context menu rather than the last set in the (long) list of default options.

Also, the default context menu seems to know whether the user is selecting a trace or not. However, the TracePopup menu option is active even when a user selects a region that does not have a trace.

The immediate use case is to allow users to have a context menu to delete points in a wave trace that is being used on an image as selection markers for background locations.

Make that +2. For my use case, I'd like to add some controls to a graph when the user clicks an item in the context menu.