diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings index 93b60bd5433e7f102927f85f591ca3d5aff1d74b..326ea49d007876ebc1eb7f81e6f616500747b2a7 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings @@ -1,6 +1,6 @@ DiagramCoordinate.java 6b00aec99054d4cd19003a72bd4e5e774ac6a641 GREEN DiagramLayers.java aa1f95dbae290c8b00202abe4385b01b8f36e5ab GREEN -DiagramViewer.java 73c3c0af460ef0631f4fc8a9d674eb6ebc804ca8 YELLOW +DiagramViewer.java 351c189b0811a472ef7728b227d4b2487f0db443 YELLOW DiagramViewerDefaultTags.java 6230763252409c60009ab8887b4ef582cf883229 GREEN DiagramViewerFeatures.java 3dd78d9c117fc156924a151c6f8d770c53c103bc GREEN DiagramViewerSelection.java e833f592543bc97077907d980a39b123fc4044e6 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java index 73c3c0af460ef0631f4fc8a9d674eb6ebc804ca8..351c189b0811a472ef7728b227d4b2487f0db443 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2020 fortiss GmbH. + * Copyright (c) 2023 fortiss GmbH. * * This program and the accompanying materials are made available under the * terms of the Apache License, Version 2.0 which is available at @@ -49,6 +49,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle; import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.MVCBundleTag; import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisualFactory; +import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.BoundingBox; import javafx.geometry.Bounds; @@ -262,6 +263,20 @@ public class DiagramViewer { if(items == null || items.isEmpty()) { return; } + + // Extend each menu item so that when it gets clicked on, it will first hide its own context + // menu before it continues with its normal procedure (to prevent old context menus being + // still open/active behind or even in front of new windows). + for(MenuItem item : items) { + EventHandler<ActionEvent> baseEventHandler = item.getOnAction(); + item.setOnAction(event -> { + hideContextMenu(); + if(baseEventHandler != null) { + baseEventHandler.handle(event); + } + }); + } + contextMenu = new ContextMenu(); contextMenu.getItems().addAll(items); contextMenu.setAutoHide(true);