0
menu.append(new MenuItem({
    label: 'Remove',
    click () {
        // action
    }
}))
menu.popup({window: remote.getCurrentWindow()})
menu.once('menu-will-close', () => {
    menu.destroy()
})

I want to set the color of menu item to be red and also want to add a icon, so anyone could help? Thank you.

Image result

Community
  • 1
  • 1
  • 2
    https://www.electronjs.org/docs/api/menu-item there doesn't seems to be any option that allows to change the item menu color. Moreover, due to the fact that it's the native menu, I suspect that there is no "legit" way to do that. However, you can definitely add an icon: https://www.electronjs.org/docs/api/menu-item#menuitemicon – briosheje Jun 04 '20 at 08:19
  • is there any working example of adding icons to the context menus – abhi matta Jun 05 '20 at 09:14
  • menuEditVin = new Menu(); menuEditVin.append(new MenuItem({ label: 'Sélectionner ...... , icon: __dirname + '/style/images/addtolist.png', – Alain BUFERNE Jun 06 '20 at 16:32
  • `menu.append(new MenuItem({ label: 'Remove', click () { self.removeArticleEntity(item) }, icon: '@/src/renderer/assets/images/test-image.jpeg' }))` Thanks for replying @AlainBUFERNE, but this is throwing me error.Is this correct – abhi matta Jun 08 '20 at 06:32
  • I add your code to one of my Menu but changing the path for the icon because doesn't correspond to anything for me. And It works. WHich error do you get ? – Alain BUFERNE Jun 08 '20 at 13:10
  • `Uncaught Error: Could not call remote function ''. Check that the function signature is correct. Underlying error: Error processing argument at index 1, conversion failure from @/src/renderer/assets/images/No_Image_Available.png Error: Could not call remote function ''. Check that the function signature is correct. Underlying error: Error processing argument at index 1, conversion failure from @/src/renderer/assets/images/No_Image_Available.png` @AlainBUFERNE this was the error! – abhi matta Jun 08 '20 at 18:15
  • I don't understand your path to the icon, put a variable and a breakpoint to see what path is computed... – Alain BUFERNE Jun 09 '20 at 07:33
  • @AlainBUFERNE I have added an image(link of image in question) to show you the error. I have used a variable and it is showing me the correct path to the image but still not able to get rid of that error. – abhi matta Jun 10 '20 at 03:30
  • try to make a simple test, actually if I understand well you are using Vue and I have no idea how it works... – Alain BUFERNE Jun 10 '20 at 12:31
  • @AlainBUFERNE I have actually figured out the path to image was wrong. Can you please tell me how to fix image size, is there any property which we can define for this? Thanks for the help. I have also added the screenshot for the image result. – abhi matta Jun 10 '20 at 15:19
  • The link for the image show the olmd error image. Personally I manged to reisze the icon to the right dimension. Anyway the menu is a native things and so no way to my sense to apply css to it so change the size of the image with an image utility. – Alain BUFERNE Jun 10 '20 at 17:02
  • Don't forget to aswer your question to close it – Alain BUFERNE Jun 11 '20 at 07:18

1 Answers1

0
menu.append(new MenuItem({label: 'Remove',click () {self.removeArticleEntity(item)},icon: 'src/renderer/assets/images/test-image.jpeg'}))

I was using the wrong path earlier, and now the icon is added when I add a correct path to an image.