mirror of
https://github.com/italicsjenga/muda.git
synced 2024-12-23 20:11:29 +11:00
chore: fix wry example context menu closes immediately
This commit is contained in:
parent
98701d0b32
commit
5fbe39e995
|
@ -166,7 +166,15 @@ fn main() -> wry::Result<()> {
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener('contextmenu', (e) => {
|
window.addEventListener('contextmenu', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
// if e.button is -1 on chromuim or e.buttons is 0 (as a fallback on webkit2gtk) then this event was fired by keyboard
|
||||||
|
if (e.button === -1 || e.buttons === 0) {
|
||||||
window.ipc.postMessage(`showContextMenu:${e.clientX},${e.clientY}`);
|
window.ipc.postMessage(`showContextMenu:${e.clientX},${e.clientY}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
window.addEventListener('mouseup', (e) => {
|
||||||
|
if (e.button === 2) {
|
||||||
|
window.ipc.postMessage(`showContextMenu:${e.clientX},${e.clientY}`);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue