How do I change the background color for a contextMenu

Hello

I am trying to change the background color for the context menu.

I have tried:

contextMenu: $(
        'ContextMenu',
        { background: 'white' }, // Adding background doesn't effect the menu
        $(
          'ContextMenuButton',
          {
            background: 'white', // Adding background doesn't effect the context menu button
          },
          $(go.TextBlock, { stroke: '#497A98', margin: 5, font: '500 15px Roboto, sans-serif' }, 'Do Something')
        ),
)

The only solution I came up with was to add a go.Panel that wraps every go.TextBlock but that seems like a lot of code for such a simple change.

Surely there must be a simpler way to set the background color for the context menu?

Also, I know of the option to use html menus but that also seems like a complex option for such a simple change.

EDIT:
After accidently bumping into a post dealing with another issue of the context menu I came upon this line:

'ButtonBorder.fill': 'white',

This solved the issue for me.

But, I have to say that with proper documentation a lot of time would have been saved.
I am sure I am not the only person looking for a simple solution to customizing the context menu items without resorting to an html solution.

You can see how "ContextMenuButton"s are defined at:
https://gojs.net/latest/extensions/Buttons.js

Thanks, but it would be much quicker for me to read properly document code rather than look around your implementation of the button.

It’s not part of the API, https://gojs.net/api, so where would you expect to read such documentation?

I don’t understand?

I get this functionality out of the box.
This, is an option in gojs that is specified in the intro.
How is it not part of the api?

If it’s a built in plugin, then it should have related documentation.
I would expect to see this in the intro section under context menu.

OK, we’ll improve the Introduction pages that talk about "ContextMenuButton"s, and of the other buttons too. Thanks for the suggestion.

1 Like