import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDoubleClickedEvent;
import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDragBegin;
import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent;
-import org.simantics.scenegraph.g2d.events.NodeEventHandler;
import org.simantics.scenegraph.g2d.events.command.CommandEvent;
import org.simantics.scenegraph.g2d.events.command.Commands;
import org.simantics.scenegraph.utils.GeometryUtils;
this.scaleRecip = 1.0 / scale;
this.caret = 0;
this.selectionTail = 0;
+
resetCaches();
}
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
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;
}
protected boolean mouseDragged(MouseDragBegin e) {
if (isHovering()
&& (isControlDown(e) || isShiftDown(e))
- && e.context instanceof NodeEventHandler
&& (dataRVI != null || text != null))
{
List<Transferable> trs = new ArrayList<>(2);