Skip to content

Commit 5bf80c6

Browse files
committed
[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
1 parent 801cd32 commit 5bf80c6

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/app/modeler/edit-mode/edit-mode.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AfterViewInit, Component, ElementRef, OnDestroy, ViewChild} from '@angular/core';
1+
import {AfterViewInit, Component, ElementRef, HostListener, OnDestroy, ViewChild} from '@angular/core';
22
import {MatDialog} from '@angular/material/dialog';
33
import {NgxDropzoneChangeEvent} from 'ngx-dropzone';
44
import {ModelImportService} from '../model-import-service';
@@ -28,6 +28,12 @@ export class EditModeComponent implements AfterViewInit, OnDestroy {
2828
) {
2929
}
3030

31+
@HostListener('contextmenu', ['$event'])
32+
onRightClick(event: MouseEvent) {
33+
event.preventDefault();
34+
event.stopPropagation();
35+
}
36+
3137
ngAfterViewInit() {
3238
ModelerUtils.clearSelection();
3339
this._editModeService.contextMenuItems.subscribe(menu => {

src/app/modeler/simulation-mode/simulation-mode.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AfterViewInit, Component, ElementRef, OnDestroy, ViewChild} from '@angular/core';
1+
import {AfterViewInit, Component, ElementRef, HostListener, OnDestroy, ViewChild} from '@angular/core';
22
import {SimulationModeService} from './simulation-mode.service';
33
import {PetriflowCanvasService} from '@netgrif/petriflow.svg';
44
import {ModelService} from '../services/model/model.service';
@@ -20,6 +20,12 @@ export class SimulationModeComponent implements AfterViewInit, OnDestroy {
2020
) {
2121
}
2222

23+
@HostListener('contextmenu', ['$event'])
24+
onRightClick(event: MouseEvent) {
25+
event.preventDefault();
26+
event.stopPropagation();
27+
}
28+
2329
ngAfterViewInit() {
2430
ModelerUtils.clearSelection();
2531
this.simulationService.originalModel.next(this.modelService.model);

src/app/modeler/simulation-mode/tool/simulation-tool.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ export abstract class SimulationTool extends CanvasListenerTool {
5757

5858
onPlaceUp(event: PointerEvent, place: CanvasPlace) {
5959
super.onPlaceUp(event, place);
60-
this.openMarkingPlaceDialog(place.modelPlace);
60+
// do not remove this setTimout - Windows user will not be happy (context menu problem)
61+
setTimeout(() => {
62+
this.openMarkingPlaceDialog(place.modelPlace);
63+
}, 0);
6164
}
6265

6366
onPlaceEnter(event: MouseEvent, place: CanvasPlace) {

0 commit comments

Comments
 (0)