0

如何在 GoJS 中获取可编辑 TextBlock 的文本?

4

3 回答 3

0

如果你想触发编辑文本块使用下面的 cade

var textBlock = myDiagram.findNodeForKey(nodekey).findObject('TextBlockName');
if (myDiagram.commandHandler.canEditTextBlock(textBlock))
    myDiagram.commandHandler.editTextBlock(textBlock);
于 2019-10-04T11:54:35.007 回答
0

将此添加到图表的 nodeTemplate。这有帮助。

$(go.TextBlock, { 可编辑: true })

 myDiagram.nodeTemplate =

    $(go.Node, "Horizontal", {
            isTreeExpanded: false,
            click: showDetail
        },
        $(go.Panel, "Auto",
            $(go.Shape, "RoundedRectangle", {
                fill: "#cce6ff", // the default fill, if there is no data-binding
                stroke: "#6699ff",
                height: 40,
                strokeWidth: 2,
                portId: "",
                cursor: "pointer", // the Shape is the port, not the whole Node
            }, new go.Binding("fill", "fill")),
            $(go.TextBlock, {
                    editable: true
                },
                new go.Binding("text", "text"))
        ),
        $("TreeExpanderButton", { alignment: go.Spot.Bottom, alignmentFocus: go.Spot.Top }, { visible: true })
    );
于 2017-02-28T06:42:46.577 回答
0

我不确定你在问什么。您的问题的字面答案是,您可以通过获取TextBlock.text属性值从任何TextBlock获取文本字符串。

但是您提到 TextBlock 是可编辑的,因此您可能会问如何在编辑期间获取 TextBlock.text 的先前值。

首先,为验证谓词提供原始字符串和新提议的字符串:TextBlock.textValidationTextEditingTool.textValidation属性以及TextEditingTool.isValidText方法。

二、“TextEdited” DiagramEvent获取原始字符串值作为DiagramEvent.parameterDiagramEvent

于 2016-06-12T14:40:29.710 回答