0

Trying to find out how to reference my Tray object. It has been created, but for some reason, I cannot seem to find out how to call it for reference. Trying via dev console...

require('electron').remote.Tray

This seems to get the native function for Tray... I have tried remote.getTray() and a few others.. I am using electron-vue. Here is my electron.js setup.

'use strict'

 const electron = require('electron')
 const path = require('path')
 const app = electron.app
 const BrowserWindow = electron.BrowserWindow
 var {Menu, Tray} = require('electron')

 let tray = null
 app.on('ready', () => {
   tray = new Tray(__dirname + '\\icons\\twitch.ico')
   const contextMenu = Menu.buildFromTemplate([
     {label: 'Item1', type: 'radio'},
     {label: 'Item2', type: 'radio'},
     {label: 'Item3', type: 'radio', checked: true},
     {label: 'Item4', type: 'radio'}
   ]);
   tray.setToolTip('Welcome')
   tray.setContextMenu(contextMenu)
 })
 ...

I do not know how to reference it correctly. Here is the Tray Documentation
My ultimate goal is to use some of the Instance Methods (located in the Tray Documentation)

Thanks!

Kaiser
  • 95
  • 2
  • 8

1 Answers1

0

You need to use ipcMain and ipcRenderer for the interaction between your UI and your Electron instance.

Let's say you wrote the following in the *.vue file:

const electron = require('electron');
const ipcRenderer = electron.ipcRenderer;
.....
.....
ipcRenderer.on('interactionSignalFromUI');

Then again in the electron.js setup you need to simply call:

Himujjal
  • 1,581
  • 1
  • 14
  • 16