nullify contextmenu

This commit is contained in:
Elijah R 2024-07-09 23:49:50 -04:00
parent b6b069450d
commit 0e4ae45d01
2 changed files with 12 additions and 9 deletions

View file

@ -83,6 +83,10 @@ export class Agent {
{ once: true } { once: true }
); );
}); });
this.cnv.addEventListener('contextmenu', e => {
e.preventDefault();
// TODO: Custom context menu support
});
document.addEventListener('mousemove', (e) => { document.addEventListener('mousemove', (e) => {
if (!this.dragging) return; if (!this.dragging) return;
this.x += e.movementX; this.x += e.movementX;
@ -180,9 +184,11 @@ export class Agent {
} }
hide(remove: boolean = false) { hide(remove: boolean = false) {
this.playAnimationByName('Hide', () => { this.playAnimationByName("Hide", () => {
if (remove) this.remove(); if(remove)
else this.cnv.style.display = 'none'; this.remove();
else
this.cnv.style.display = 'none';
}); });
} }
} }

View file

@ -3,6 +3,7 @@
import * as msagent from "@msagent-chat/msagent.js"; import * as msagent from "@msagent-chat/msagent.js";
let w = window as any; let w = window as any;
w.agents = [];
let input = document.getElementById("testbed-input") as HTMLInputElement; let input = document.getElementById("testbed-input") as HTMLInputElement;
input.addEventListener("change", async () => { input.addEventListener("change", async () => {
@ -11,12 +12,8 @@ input.addEventListener("change", async () => {
console.log("Creating agent"); console.log("Creating agent");
let agent = msagent.agentCreateCharacter(new Uint8Array(buffer)); let agent = msagent.agentCreateCharacter(new Uint8Array(buffer));
// destroy the previous agent w.agents.push(agent);
if(w.agent != null) {
w.agent.hide(true);
}
w.agent = agent;
agent.addToDom(document.body); agent.addToDom(document.body);
agent.show(); agent.show();