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

View file

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