preventing rmb

This commit is contained in:
BroodjeAap 2022-09-18 09:08:13 +00:00
parent 7d0f1ce8c9
commit e6d8e0fa98
2 changed files with 16 additions and 7 deletions

View file

@ -75,6 +75,9 @@ function diagramOnMouseMove(ev) {
function diagramOnWheel(ev) { function diagramOnWheel(ev) {
//_diagram.onwheel(ev); //_diagram.onwheel(ev);
} }
function diagramOnContext(ev) {
ev.preventDefault();
}
var Diagrams = /** @class */ (function () { var Diagrams = /** @class */ (function () {
function Diagrams(canvasId) { function Diagrams(canvasId) {
this.nodes = new Array(); this.nodes = new Array();
@ -105,6 +108,7 @@ var Diagrams = /** @class */ (function () {
this.canvas.onmousedown = diagramOnMouseDown; this.canvas.onmousedown = diagramOnMouseDown;
this.canvas.onmouseup = diagramOnMouseUp; this.canvas.onmouseup = diagramOnMouseUp;
this.canvas.onwheel = diagramOnWheel; this.canvas.onwheel = diagramOnWheel;
this.canvas.oncontextmenu = diagramOnContext;
window.onresize = diargramOnResize; window.onresize = diargramOnResize;
} }
Diagrams.prototype.onmousemove = function (ev) { Diagrams.prototype.onmousemove = function (ev) {
@ -181,6 +185,9 @@ var Diagrams = /** @class */ (function () {
this.panning = true; this.panning = true;
}; };
Diagrams.prototype.onmouseup = function (ev) { Diagrams.prototype.onmouseup = function (ev) {
if (ev.button != 0) {
return;
}
this.panning = false; this.panning = false;
this.nodeDragging = null; this.nodeDragging = null;
if (this.makingConnectionNode !== null) { if (this.makingConnectionNode !== null) {
@ -324,8 +331,6 @@ var Diagrams = /** @class */ (function () {
Diagrams.prototype.removeConnection = function (A, B) { Diagrams.prototype.removeConnection = function (A, B) {
this.connections.splice(this.connections.indexOf([A, B]), 1); this.connections.splice(this.connections.indexOf([A, B]), 1);
}; };
Diagrams.prototype.drawDiagramNode = function (node) {
};
Diagrams.prototype.fillParent = function () { Diagrams.prototype.fillParent = function () {
this.canvas.width = this.canvas.clientWidth; this.canvas.width = this.canvas.clientWidth;
this.canvas.height = this.canvas.clientHeight; this.canvas.height = this.canvas.clientHeight;

View file

@ -99,6 +99,9 @@ function diagramOnMouseMove(ev: MouseEvent){
function diagramOnWheel(ev: WheelEvent){ function diagramOnWheel(ev: WheelEvent){
//_diagram.onwheel(ev); //_diagram.onwheel(ev);
} }
function diagramOnContext(ev: MouseEvent){
ev.preventDefault();
}
class Diagrams { class Diagrams {
canvas: HTMLCanvasElement; canvas: HTMLCanvasElement;
@ -140,6 +143,7 @@ class Diagrams {
this.canvas.onmousedown = diagramOnMouseDown; this.canvas.onmousedown = diagramOnMouseDown;
this.canvas.onmouseup = diagramOnMouseUp; this.canvas.onmouseup = diagramOnMouseUp;
this.canvas.onwheel = diagramOnWheel; this.canvas.onwheel = diagramOnWheel;
this.canvas.oncontextmenu = diagramOnContext;
window.onresize = diargramOnResize; window.onresize = diargramOnResize;
} }
@ -218,6 +222,10 @@ class Diagrams {
} }
onmouseup(ev: MouseEvent){ onmouseup(ev: MouseEvent){
if (ev.button != 0){
return;
}
this.panning = false; this.panning = false;
this.nodeDragging = null; this.nodeDragging = null;
if (this.makingConnectionNode !== null){ if (this.makingConnectionNode !== null){
@ -388,11 +396,7 @@ class Diagrams {
removeConnection(A: DiagramNode, B: DiagramNode){ removeConnection(A: DiagramNode, B: DiagramNode){
this.connections.splice(this.connections.indexOf([A, B]), 1); this.connections.splice(this.connections.indexOf([A, B]), 1);
} }
drawDiagramNode(node: DiagramNode){
}
fillParent(){ fillParent(){
this.canvas.width = this.canvas.clientWidth; this.canvas.width = this.canvas.clientWidth;
this.canvas.height = this.canvas.clientHeight; this.canvas.height = this.canvas.clientHeight;