]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextNode.java
Use element transform when doing pick check
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / elements / TextNode.java
index 0b33ae3c4f65dda2250adf361cfeb7868d872056..77eb789220d3118e5d8c370c2889b731450e060f 100644 (file)
@@ -410,6 +410,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
         this.scaleRecip = 1.0 / scale;
         this.caret = 0;
         this.selectionTail = 0;
+        
 
         resetCaches();
     }
@@ -857,6 +858,18 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
     protected void renderSelectedHover(Graphics2D g, boolean isSelected, boolean isHovering) {
     }
 
+    public String editText(String text) {
+
+        String error = validator != null ? validator.apply(text) : null;
+        if (error == null) {
+            this.text = text;
+            if (textListener != null) {
+                textListener.textEditingEnded();
+            }
+        }
+        return error;
+    }
+
     /**
      * Replaces the current selection with the content or inserts
      * the content at caret. After the insertion the caret
@@ -1425,6 +1438,9 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
             y += line.layout.getDescent() + line.layout.getLeading() + line.layout.getAscent();
 
             Rectangle2D bbox = line.layout.getLogicalHighlightShape(0, lineText.length()).getBounds2D();
+            // HighlightShape is not large enough, if font is italic.
+            Rectangle2D bbox2 = line.layout.getBounds();
+            bbox.add(bbox2);
             bbox.setFrame(bbox.getX(), bbox.getY() + line.drawPosY, bbox.getWidth(), bbox.getHeight());
             line.bbox = bbox;
         }