Treverix / custom-electron-titlebar

Custom electon title bar inpire on VS Code title bar
MIT License
35 stars 6 forks source link

All methods return 'is not a function' #13

Closed GreepTheSheep closed 4 years ago

GreepTheSheep commented 4 years ago

Describe the bug When you call a method (either updateBackground or updateTitle) it shows 'is not a function'

Screenshots If applicable, add screenshots to help explain your problem. image image

Desktop (please complete the following information):

Treverix commented 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.

GreepTheSheep commented 4 years ago

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)

Treverix commented 4 years ago

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.

GreepTheSheep commented 4 years ago

I think I need some help... I called the function in the preload file. ipcMain was loaded from https://github.com/Treverix/remote image But it return this in node console: image

Treverix commented 4 years ago

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

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.