railsware / bozon

🛠 Command line tool for building, testing and publishing modern Electron applications
MIT License
758 stars 52 forks source link

Not working the NativeImage class static functions #60

Closed umutc closed 5 years ago

umutc commented 5 years ago

new Tray(NativeImage.createEmpty());

uncaughtException: Cannot read property 'createEmpty' of undefined
TypeError: Cannot read property 'createEmpty' of undefined
at registerTray (/Users/umutcelik/viadirect/viadirect-oriantation/builds/development/javascripts/main/index.js:202:55)
at App.initApp (/Users/umutcelik/viadirect/viadirect-oriantation/builds/development/javascripts/main/index.js:222:5)
at App.emit (events.js:187:15)
alchaplinsky commented 5 years ago

@umutc NativeImage is undefined. Do you have it imported at the top of your file?

umutc commented 5 years ago

@alchaplinsky yes it is bozon@0.8.12

const { app, globalShortcut, BrowserWindow, ipcMain, Menu, Tray, shell, NativeImage } = require('electron');

const displaySettingsWindow = () => console.log('displaySettingsWindow');
const displaySettingsWindow = () => console.log('displaySettingsWindow');
const quitImmediatly = () => console.log('quitImmediatly');

app.on('ready', () => {
  tray = new Tray(NativeImage.createEmpty());
  const contextMenu = Menu.buildFromTemplate([
    { label: 'settings', type: 'normal', click: displaySettingsWindow },
    { label: 'clearCache', type: 'normal', click: clearCache },
    { label: 'close', type: 'normal', click: quitImmediatly },
  ])
  tray.setToolTip('App')
  tray.setContextMenu(contextMenu)
});
umutc commented 5 years ago

The problem was related to an image size larger than 32px