mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-07 02:11:28 +08:00
Fix context menu example
This commit is contained in:
parent
2b9891da2c
commit
f19cc528d4
@ -3,16 +3,33 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Title</title>
|
<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>
|
<style>.region{ width: 100%; border: 3px solid #00a4db; }</style>
|
||||||
<script type="module" src="/wails/runtime.js"></script>
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Context Menu Demo</h1>
|
<h1>Context Menu Demo</h1>
|
||||||
<p>
|
<p>
|
||||||
You need to run this example in production for it to work :
|
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>
|
<pre id="cmd" style="color: rgb(219, 219, 134)">go run -tags production .</pre>
|
||||||
</p>
|
<button id="copyButton" style="pointer-events: auto;">Copy</button>
|
||||||
<br/>
|
<br/>
|
||||||
<div class="region" id="123abc" style="--custom-contextmenu: test; --custom-contextmenu-data: 1">
|
<div class="region" id="123abc" style="--custom-contextmenu: test; --custom-contextmenu-data: 1">
|
||||||
<h1>1</h1>
|
<h1>1</h1>
|
||||||
|
@ -5,4 +5,4 @@ package runtime
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
import goruntime "runtime"
|
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