csepulv / electron-with-create-react-app

Sample Electron application using create-react-app
MIT License
831 stars 217 forks source link

Can't get click event to register at all in desktop app... works in the browser #27

Open dascoder opened 5 years ago

dascoder commented 5 years ago

Running Electron + react set up according to your guide here. I added a simple app bar from material and created a react class from the component.

However the components in the window launched by electron.exe are not responsive. If I go to localhost:3000 then I find that the buttons are responsive and trigger events, everything works!

Any tips to help me investigate?

csepulv commented 5 years ago

I don't know. If I add this to App.js, I see the messages in the console.

<button onClick={()=>{console.log("Button Pressed")}}>
          Push me
</button>

I would start with simple buttons. There may be an issue with material-ui, but that unfortunately might mean debugging that side of things.

dascoder commented 5 years ago

Interesting. I've removed material and tried the same experiment. in the component constructor this.toggleWindowVisibility = this.toggleWindowVisibility.bind(this)

the function

toggleWindowVisibility(){ 
  if (document.visibilityState === "visible")
  {
    log.info("Clicked minimize!")
    window.dispatchEvent(new Event('minimize'))
    return
  }
  log.info("Window is not visible")
  window.moveTo(0,0);
}

In the render function <button onClick={this.toggleWindowVisibility}}> Push me </button>

still no event triggered.