FYI, I ended up doing a "brute force" loop in my StartupFcn to create 18 different Context menus, each specialized to the box they're spawned from. It won't be helpful to post all of my code here, as it depends on other functions I already created (mainly a function that can retrieve a handle any of the 18 boxes based on certain parameters) that are highly specialized to my app. But, basically, I use a set of loops that loops through the properties that define my boxes, then create a uicontextmenu with a UserData property equal to the properties of that box. All of the uimenu Children created also have the same UserData property. I then set a callback function (with requiresEventData set to true) for each child menu which reads event.Source.UserData and passes it on to the functions that I need to run based on the selection.
Here's an excerpt from inside my for loop. This creates a context menu with an opening call back and 3 selections, "Remove Variable", 'Set Variable Color", and an "Edit Variable" selection who's exact text depends on which box is calling it.
figApp = app.AppFigure;
callbackContext = createCallbackFcn(app, @menuVariablesContextMenuOpening, true);
menuContext = uicontextmenu(figApp, 'ContextMenuOpeningFcn', callbackContext, 'UserData', thisBox);
callbackRemove = createCallbackFcn(app, @removeVariable, true);
menuRemove = uimenu(menuContext, 'Text', 'Remove Variable', 'MenuSelectedFcn', callbackRemove, 'UserData', thisBox );
callbackColor = createCallbackFcn(app, @setVariableColor, true);
menuEdit = uimenu(menuContext, 'Text', 'Set Variable Color', 'MenuSelectedFcn', callbackColor, 'UserData', thisBox );
callbackEdit = createCallbackFcn(app, @editVariable, true);
menuEdit = uimenu(menuContext, 'Text', txtEdit, 'MenuSelectedFcn', callbackEdit, 'UserData', thisBox );
Some of the names:
figApp is a handle to the main app figure (named AppFigure in this example)
menuVariablesContextMenuOpening is my callback function for the menu opening
txtEdit is a contextual char array which is different for each box
thisBox is a struct with all the properties of each box that I need
This code is inside a set of loops that iterate a total of 18 times, so It creates 18 different context menus in my App, but the only thing that makes each menu different is the UserData (and text on the edit menu). They all call the same set of callback functions, which then uses event.source.UserData to differentiate which one is calling and what actions it should take.
If anyone else is looking for something similar, hopefully this helps. Kind of brute force, but at least I didn't have to sit and create 18 different context menus in App Designer. This way, it will be easy to make a change that will affect all 18 and not have to edit 18 different context menus, either.