docs: update clipboard fiddles (#36946)

This commit is contained in:
David Sanders 2023-01-19 11:59:35 -08:00 committed by GitHub
parent 55c818d0a8
commit 4e4ae9ff53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 55 additions and 20 deletions

View file

@ -1,4 +1,5 @@
const { app, BrowserWindow } = require('electron')
const { app, BrowserWindow, ipcMain, clipboard } = require('electron')
const path = require('path')
let mainWindow = null
@ -8,7 +9,7 @@ function createWindow () {
height: 400,
title: 'Clipboard copy',
webPreferences: {
nodeIntegration: true
preload: path.join(__dirname, 'preload.js')
}
}
@ -20,6 +21,18 @@ function createWindow () {
})
}
ipcMain.handle('clipboard:writeText', (event, text) => {
clipboard.writeText(text)
})
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})