Created
October 6, 2019 08:47
-
-
Save RikTheunis/263e01f09c1cb44da8d8bf28f2f726ce to your computer and use it in GitHub Desktop.
Electron Fiddle Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<div> | |
<div> | |
<h1>Supports: Win, macOS, Linux <span>|</span> Process: Both</div> | |
<div> | |
<div> | |
<button id="copy-to">Copy</button> | |
<input id="copy-to-input" aria-label="Click copy" placeholder="Click copy."></input> | |
</div> | |
<p>In this example we copy a phrase to the clipboard. After clicking 'Copy' use the text area to paste (CMD + V or CTRL + V) the phrase from the clipboard.</p> | |
</div> | |
</div> | |
</div> | |
</body> | |
<script> | |
require('./renderer.js') | |
</script> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { app, BrowserWindow } = require('electron') | |
let mainWindow = null | |
function createWindow () { | |
const windowOptions = { | |
width: 600, | |
height: 400, | |
title: 'Clipboard copy', | |
webPreferences: { | |
nodeIntegration: true | |
} | |
} | |
mainWindow = new BrowserWindow(windowOptions) | |
mainWindow.loadFile('index.html') | |
mainWindow.on('closed', () => { | |
mainWindow = null | |
}) | |
} | |
app.on('ready', () => { | |
createWindow() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {clipboard} = require('electron') | |
const copyBtn = document.getElementById('copy-to') | |
const copyInput = document.getElementById('copy-to-input') | |
copyBtn.addEventListener('click', () => { | |
if (copyInput.value !== '') copyInput.value = '' | |
copyInput.placeholder = 'Copied! Paste here to see.' | |
clipboard.writeText('Electron Demo!') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment