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

**URL:** <https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603>\
**Category:** Support\
**Created:** [July 9, 2021, 3:35pm UTC](https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603 "2021-07-09T15:35:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [July 9, 2021, 3:35pm UTC](https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603/1 "2021-07-09T15:35:09Z")

</div>

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](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository/subjecthierarchy.html?highlight=context%20menu#use-whitelist-to-customize-view-menu)

[https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/9/49f4558beccf23a939536fa23b2aada495b7e0d3.mp4](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/9/49f4558beccf23a939536fa23b2aada495b7e0d3.mp4)

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [July 9, 2021, 3:38pm UTC](https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603/2 "2021-07-09T15:38:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [July 9, 2021, 3:41pm UTC](https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603/3 "2021-07-09T15:41:21Z")

</div>

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.

[https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/d/2d4eaa5c0f4828f397064336a38f703a224cebca.mp4](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/d/2d4eaa5c0f4828f397064336a38f703a224cebca.mp4)

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [July 9, 2021, 3:43pm UTC](https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603/4 "2021-07-09T15:43:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [July 9, 2021, 3:59pm UTC](https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603/5 "2021-07-09T15:59:01Z")

</div>

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](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/9/a9b100e66fffb59f1416394b517f565291c41d03.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/b/6bda85ba53c3c5f790ff8736faa00c09657c7737.png)

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [July 9, 2021, 4:15pm UTC](https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603/6 "2021-07-09T16:15:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 9, 2021, 5:22pm UTC](https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603/7 "2021-07-09T17:22:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [July 9, 2021, 6:04pm UTC](https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603/8 "2021-07-09T18:04:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 9, 2021, 8:01pm UTC](https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603/9 "2021-07-09T20:01:18Z")

</div>

Pushed a fix:

> <https://github.com/Slicer/Slicer/pull/5732>
>
> List of allowed view context menu actions was reset whenever the menu was rebuil…t.
> Fixed by introducing a string list that stores the allowed action names.
> 
> https://discourse.slicer.org/t/customization-of-right-click-context-menu-is-being-reset-to-default-unexpectedly/18603/7
