I want to simulate a mobile device in desktop environment. I can't find a argument to transform mouse event to touch event.
How can I approach this job? Any hint will be great. Thank you so much.
I think I figured it out. Dev environment:
    const app = electron.app 
    const BrowserWindow = electron.BrowserWindow
    let mainWindow;
    function createWindow() {
      mainWindow = new BrowserWindow({
        width: 1024,
        height: 768,
        frame: false,
        x: -1920,
        y: 0,
        autoHideMenuBar: true,
        icon: 'assets/icons/win/app-win-icon.ico'
      });
      try {
        // works with 1.1 too
        mainWindow.webContents.debugger.attach('1.2')
      } catch (err) {
        console.log('Debugger attach failed: ', err)
      }
      const isDebuggerAttached = mainWindow.webContents.debugger.isAttached()
      console.log('debugger attached? ', isDebuggerAttached)
      mainWindow.webContents.debugger.on('detach', (event, reason) => {
        console.log('Debugger detached due to: ', reason)
      });
      // This is where the magic happens!
      mainWindow.webContents.debugger.sendCommand('Emulation.setTouchEmulationEnabled', {
        enabled: true,
        configuration: 'mobile',
      });
      mainWindow.loadURL(url.format({
        pathname: path.join(__dirname, 'index.html'),
        protocol: 'file:',
        slashes: true,
        show: false,
        backgroundColor: '#8e24aa ',
      }));
      // Show the mainwindow when it is loaded and ready to show
      mainWindow.once('ready-to-show', () => {
          mainWindow.show()
      })
    }
    // Listen for app to be ready
    app.on('ready', createWindow);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With