Skip to content

Commit

Permalink
Disable global right-click menu; Add right-click copy command;
Browse files Browse the repository at this point in the history
  • Loading branch information
kerwin612 committed Jun 26, 2023
1 parent 0d33007 commit ee0635b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gui",
"private": true,
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"scripts": {
"tauri": "tauri"
Expand Down
2 changes: 1 addition & 1 deletion gui/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gui/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "portable_runner_gui"
version = "0.0.3"
version = "0.0.4"
authors = ["kerwin612 <kerwin612@qq.com>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion gui/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "PortableRunner",
"version": "0.0.3"
"version": "0.0.4"
},
"tauri": {
"allowlist": {
Expand Down
18 changes: 18 additions & 0 deletions gui/src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { invoke } = window.__TAURI__.tauri;
const { writeText } = window.__TAURI__.clipboard;

let containerSet;
let containerCmd;
Expand Down Expand Up @@ -126,6 +127,21 @@ function refreshCmd() {
cmdClick(i.cmd);
}
};
ie.onmousedown = (e) => {
let isRightMB;
e = e || window.event;

if ("which" in e) // Gecko (Firefox), WebKit (Safari/Chrome) & Opera
isRightMB = e.which == 3;
else if ("button" in e) // IE, Opera
isRightMB = e.button == 2;

if (isRightMB) {
writeText(i.cmd).then(_ => {
//
});
}
}

});
}
Expand Down Expand Up @@ -160,3 +176,5 @@ window.addEventListener("DOMContentLoaded", () => {
window.addEventListener('focus', () => {
refreshCmd();
});

document.addEventListener('contextmenu', event => event.preventDefault());

0 comments on commit ee0635b

Please sign in to comment.