*/\r
public class DiagramViewer extends org.simantics.modeling.ui.diagramEditor.DiagramViewer {\r
\r
- /*@Override\r
- public void setFocus() {\r
- System.out.println("diagram setFocus()");\r
- super.setFocus();\r
- }*/\r
- \r
protected String getPopupId() {\r
return "#SysdynDiagramPopup";\r
}\r
\r
import org.simantics.diagram.elements.TextNode;\r
import org.simantics.scenegraph.ISelectionPainterNode;\r
+import org.simantics.scenegraph.g2d.events.EventTypes;\r
+import org.simantics.scenegraph.g2d.events.FocusEvent;\r
import org.simantics.scenegraph.utils.NodeUtil;\r
\r
public class HoverTextNode extends TextNode implements ISelectionPainterNode {\r
g.setTransform(ot);\r
}\r
\r
+ @Override\r
+ public void init() {\r
+ super.init();\r
+ addEventHandler(this);\r
+ }\r
+ \r
+ @Override\r
+ public int getEventMask(){\r
+ return EventTypes.FocusLostMask | super.getEventMask();\r
+ }\r
+ \r
+ @Override\r
+ protected boolean handleFocusEvent(FocusEvent e) {\r
+ int eventType = EventTypes.toType(e);\r
+ if (eventType == EventTypes.FocusLost){\r
+ //If focus of the element (and the diagram) is lost, save the name of the node\r
+ fireTextEditingEnded();\r
+ }\r
+ return false;\r
+ }\r
+ \r
}\r