Customization of right-click context menu is being reset to default unexpectedly

I’m trying to modify visible options of the right-click context menu, but my customization is not being maintained. I haven’t figured out what causes it by it ultimately returns to the default right-click context menu and reverting my customization.

I’m doing the right-click context menu customization using
https://slicer.readthedocs.io/en/latest/developer_guide/script_repository/subjecthierarchy.html?highlight=context%20menu#use-whitelist-to-customize-view-menu

There was a recent change in the API, it’s probably just that the example script has not been updated. Let me look into it.

Appears to happen when I customize and then I right-click in the open area to bring up the transform/adjust Window/Level/Place/Copy menu. Then when right-clicking over the markups it is different from the beginning.

My suspicion was not right, the function names are correct…

Was there a defined way to customize the right-click context menu of the Slice view versus the right-click context menu on a markups point? I would guess this is contributing to the problem as one is probably redefining the other?

image
image

You are probably right. The view context menu was recently overhauled by @lassoan so I’d refer to him with this, since he is more familiar with the latest code.

I’ve checked the code and the menu is rebuilt after a menu is constructed without any visible items (because none of the DisplayedViewContextMenuActionNames were visible when you right-clicked on the view background). This problem has not come up before because the menu was only available for markups. I’ll push a fix later today.

1 Like

Thanks! I guess those 4 empty string “” entries returned by availableViewContextMenuActionNames() were those 4 new slice view context menu actions.

I guess if they weren’t empty string named actions, then I probably could have customized to something like newActions = ["ToggleSelectPointAction", "ViewTransformAction"] to have at least one action in both menus and then they would not get recreated from default and maintain the customization.

Pushed a fix: