From 5bf80c64e52270da6039c4147fd995a5af2ae60c Mon Sep 17 00:00:00 2001 From: Jozef Daxner Date: Thu, 3 Apr 2025 15:57:37 +0200 Subject: [PATCH 1/2] [NAB-374] Right click shows default browser context menu - fix right click opening default browser context menu instead of custom application menu - fixed in edit + simulation view --- src/app/modeler/edit-mode/edit-mode.component.ts | 8 +++++++- .../modeler/simulation-mode/simulation-mode.component.ts | 8 +++++++- src/app/modeler/simulation-mode/tool/simulation-tool.ts | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/app/modeler/edit-mode/edit-mode.component.ts b/src/app/modeler/edit-mode/edit-mode.component.ts index 2430ee6..67a0497 100644 --- a/src/app/modeler/edit-mode/edit-mode.component.ts +++ b/src/app/modeler/edit-mode/edit-mode.component.ts @@ -1,4 +1,4 @@ -import {AfterViewInit, Component, ElementRef, OnDestroy, ViewChild} from '@angular/core'; +import {AfterViewInit, Component, ElementRef, HostListener, OnDestroy, ViewChild} from '@angular/core'; import {MatDialog} from '@angular/material/dialog'; import {NgxDropzoneChangeEvent} from 'ngx-dropzone'; import {ModelImportService} from '../model-import-service'; @@ -28,6 +28,12 @@ export class EditModeComponent implements AfterViewInit, OnDestroy { ) { } + @HostListener('contextmenu', ['$event']) + onRightClick(event: MouseEvent) { + event.preventDefault(); + event.stopPropagation(); + } + ngAfterViewInit() { ModelerUtils.clearSelection(); this._editModeService.contextMenuItems.subscribe(menu => { diff --git a/src/app/modeler/simulation-mode/simulation-mode.component.ts b/src/app/modeler/simulation-mode/simulation-mode.component.ts index d961e60..0fcd44b 100644 --- a/src/app/modeler/simulation-mode/simulation-mode.component.ts +++ b/src/app/modeler/simulation-mode/simulation-mode.component.ts @@ -1,4 +1,4 @@ -import {AfterViewInit, Component, ElementRef, OnDestroy, ViewChild} from '@angular/core'; +import {AfterViewInit, Component, ElementRef, HostListener, OnDestroy, ViewChild} from '@angular/core'; import {SimulationModeService} from './simulation-mode.service'; import {PetriflowCanvasService} from '@netgrif/petriflow.svg'; import {ModelService} from '../services/model/model.service'; @@ -20,6 +20,12 @@ export class SimulationModeComponent implements AfterViewInit, OnDestroy { ) { } + @HostListener('contextmenu', ['$event']) + onRightClick(event: MouseEvent) { + event.preventDefault(); + event.stopPropagation(); + } + ngAfterViewInit() { ModelerUtils.clearSelection(); this.simulationService.originalModel.next(this.modelService.model); diff --git a/src/app/modeler/simulation-mode/tool/simulation-tool.ts b/src/app/modeler/simulation-mode/tool/simulation-tool.ts index 6ead3e9..4c6f3dd 100644 --- a/src/app/modeler/simulation-mode/tool/simulation-tool.ts +++ b/src/app/modeler/simulation-mode/tool/simulation-tool.ts @@ -57,7 +57,10 @@ export abstract class SimulationTool extends CanvasListenerTool { onPlaceUp(event: PointerEvent, place: CanvasPlace) { super.onPlaceUp(event, place); - this.openMarkingPlaceDialog(place.modelPlace); + // do not remove this setTimout - Windows user will not be happy (context menu problem) + setTimeout(() => { + this.openMarkingPlaceDialog(place.modelPlace); + }, 0); } onPlaceEnter(event: MouseEvent, place: CanvasPlace) { From 9b380eb53e1aee4c9f88349a9ed9231580888657 Mon Sep 17 00:00:00 2001 From: Jozef Daxner Date: Thu, 3 Apr 2025 16:55:24 +0200 Subject: [PATCH 2/2] [NAB-374] Right click shows default browser context menu - fix right click on arc in simulation view --- src/app/modeler/simulation-mode/tool/simulation-tool.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/modeler/simulation-mode/tool/simulation-tool.ts b/src/app/modeler/simulation-mode/tool/simulation-tool.ts index 4c6f3dd..60d9bc2 100644 --- a/src/app/modeler/simulation-mode/tool/simulation-tool.ts +++ b/src/app/modeler/simulation-mode/tool/simulation-tool.ts @@ -79,10 +79,14 @@ export abstract class SimulationTool extends CanvasListenerTool { if (value === undefined) { const place = this.simulationModeService.model.getPlace(reference); if (place) { - this.openMarkingPlaceDialog(place); + setTimeout(() => { + this.openMarkingPlaceDialog(place); + }, 0); } } else { - this.openDataDialog(reference, value); + setTimeout(() => { + this.openDataDialog(reference, value); + }, 0); } }