Closed GreepTheSheep closed 4 years ago
I couldn't reproduce that. I added both method calls inside the example app (preload) and it changed title and background as expected. Please add more info to show how you used the library.
I see that you probably used it on the render.js
script while the example application defines the titlebar on the preload.js
.
yeah i put it in the render.js
and i didn't know where to put it. I used a form to change the title in this screenshot and it calls the function ok() in the render file (linked with the HTML file)
So all methods should run in preload file ? And can IPCs run in preload file ? (I have a doubt about this)
Honestly, I never tried using the titlebar on a render script, I always used it with the preload. So I can't tell if or how it will work and what are benefits or limitations.
You could try creating the titlebar on the preload and adding it as window.titlebar
to access it from the render script later.
IPC works fine on the preload. That's something I use always on my apps.
I close this ticket as it does not seem to be a bug or an issue.
I think I need some help... I called the function in the preload file. ipcMain was loaded from https://github.com/Treverix/remote But it return this in node console:
ipcMain
is for the main process, you need to use ipcRender
on preload and render scripts. If you want to send a message from the render to the preload script via ipc, then you could try to
ipcRender.invoke('title-updated', 'new title)
)ipcMain.handle('title-updated', (e, title) => {webContents.send('titlebar-update-title', title)}
ipcRenderer.on('titlebar-update-title', (e, title) => {titleBar.updateTitle(title)})
As a rough idea, not sure if the syntax is 100% OK.
Otherwise, as I suggested, try adding the titlebar
reference to window
or document
to use it on the render script also.
Describe the bug When you call a method (either
updateBackground
orupdateTitle
) it shows 'is not a function'Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):