Skip to content
Snippets Groups Projects
Commit e559243a authored by Sebastian Bergemann's avatar Sebastian Bergemann
Browse files

Ensure hiding the context menu directly before its menu item actions

Issue-Ref: 4321
Issue-Url: af3#4321



Signed-off-by: default avatarSebastian Bergemann <bergemann@fortiss.org>
parent 86c97797
No related branches found
No related tags found
1 merge request!204Ensure hiding the context menu directly before its menu item actions
Pipeline #38731 failed
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
......
/*******************************************************************************
* 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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment