mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 02:39:30 +08:00
Fix context menu example
This commit is contained in:
parent
2b9891da2c
commit
f19cc528d4
@ -3,16 +3,33 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<style>body{ text-align: center; color: white; background-color: #191919; }</style>
|
||||
<style>body{ text-align: center; color: white; background-color: #191919;}</style>
|
||||
<style>.region{ width: 100%; border: 3px solid #00a4db; }</style>
|
||||
<script type="module" src="/wails/runtime.js"></script>
|
||||
<script type="module">
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
let copyButton = document.querySelector('#copyButton');
|
||||
copyButton.addEventListener('click', function(event) {
|
||||
let preElement = document.querySelector('#cmd');
|
||||
let text = preElement.textContent.trim();
|
||||
navigator.clipboard.writeText(text).then(function() {
|
||||
console.log('Copying to clipboard was successful!');
|
||||
// Select the text in the pre element
|
||||
let selection = window.getSelection();
|
||||
selection.selectAllChildren(preElement);
|
||||
}, function(err) {
|
||||
console.error('Could not copy text: ', err);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Context Menu Demo</h1>
|
||||
<p>
|
||||
You need to run this example in production for it to work :
|
||||
<pre style="user-select: text; color: rgb(219, 219, 134)">go run -tags production .</pre>
|
||||
</p>
|
||||
<pre id="cmd" style="color: rgb(219, 219, 134)">go run -tags production .</pre>
|
||||
<button id="copyButton" style="pointer-events: auto;">Copy</button>
|
||||
<br/>
|
||||
<div class="region" id="123abc" style="--custom-contextmenu: test; --custom-contextmenu-data: 1">
|
||||
<h1>1</h1>
|
||||
|
@ -5,4 +5,4 @@ package runtime
|
||||
import "fmt"
|
||||
import goruntime "runtime"
|
||||
|
||||
var environment = fmt.Sprintf(`window._wails.environment={"OS":"%s","Arch":"%s","Debug":true};`, goruntime.GOOS, goruntime.GOARCH)
|
||||
var environment = fmt.Sprintf(`window._wails.environment={"OS":"%s","Arch":"%s","Debug":false};`, goruntime.GOOS, goruntime.GOARCH)
|
||||
|
Loading…
Reference in New Issue
Block a user