HTMLInfo.show() is not called

Dear support,
my use case is to have some ‘choices’ on the “MAPPEDINSTANCE”-TextBoxes. The HTMLInfo.show() function is not called. Clicking on the above “NAME”-TextBlock the show()-function is called.
What should I do to enable the show-function clicking on the MAPPEDINSTANCE-TextBoxes. These are defined in the “subComponentsTemplate”. Thanks in advance!

var subComponentsTemplate =
	$(go.Panel, "Horizontal",
		
		$(go.Picture,
			{ 
			margin: new go.Margin(5, 5, 5, 3) , // top, right, bottom, left, 
			desiredSize: new go.Size(30, 30), source: "./ProcessArchitect_files/LogoFesto.png"},
			new go.Binding("source", "iconRequiredComponent"),
		),
		
		$(go.TextBlock,  // >>> clicking here HTMLInfo.show() is NOT called ! <<<
			{ 	name: "MAPPEDINSTANCE",
				editable: true,
				font: "8pt Verdana, sans-serif" ,
				choices: ['One', 'Two', 'Three', 'Four'] // TEST
			},
			new go.Binding("choices")),
		)
	);


myWorkspace =
	$(go.Diagram, "divWorkspace",
		{ 	maxSelectionCount: 1, 
			"undoManager.isEnabled": true,
		}
	);

myWorkspace.nodeTemplate =
	$(go.Node, "Auto",
		{  
		locationSpot: go.Spot.Top,
		
		},
		new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
				
		$(go.Shape, "RoundedRectangle",
			{ name: "SHAPE", fill: "#B4B4B4", strokeWidth: 0 ,
			  parameter1: 10, 
			  portId: "", fromLinkable: true, toLinkable: true,
              fromLinkableDuplicates: true, toLinkableDuplicates: true,
              fromLinkableSelfNode: true, toLinkableSelfNode: true
			},
			new go.Binding("figure")
		),
		
			// main panel
			$(go.Panel, "Vertical",
				{ name: "MAIN_PANEL" },
			
				//  app icon / app name | name
				$(go.Panel, "Horizontal",
				{ alignment: go.Spot.Left },
				
					// app icon / app name
					$(go.Panel, "Vertical", 
					
						// app icon
						$(go.Picture,
							{ 
								//alignment: go.Spot.Left,
								desiredSize: new go.Size(40, 40), source: "./ProcessArchitect_files/LogoFesto.png",
								margin: new go.Margin(3, 3, 3, 5) , // top, right, bottom, left
							},
							new go.Binding("source", "icon")
						),
					),
					
					// name / PanelExpanderButton / 'SubComponents'
					$(go.Panel, "Vertical", 
						// name
						$(go.TextBlock,
						  { name: "NAME",
							//alignment: go.Spot.Right,
							editable: true,
							margin: 3,
							font: "bold 12px Roboto, sans-serif",
							stroke: "rgba(0, 0, 0, .87)",
							maxSize: new go.Size(160, 80),
						  },
						  new go.Binding("text", "name").makeTwoWay(), // graphic <-> update model !!
						),
												
						$(go.Panel, "Horizontal", 
							{ alignment: go.Spot.Right },
						 
							$(go.Shape, "Circle",
								{
								  margin: new go.Margin(8, 8, 0, 10), // top, right, bottom, left
								  width: 10, height: 10, fill: "red", stroke: null
								},
							),
							$(go.TextBlock,
							  { text: "required components",
								margin: mt8,
								font: "10px Roboto, sans-serif",
								stroke: "rgba(0, 0, 0, .87)",
							  }
							 ),
						  
							$("PanelExpanderButton", "SUBCOMPONENTS",
								{ margin: new go.Margin(8, 0, 0, 8) } // top, right, bottom, left
							)
						)
					),	
				), 
				
				$(go.Shape, "LineH",
				  {
					stroke: "rgba(0, 0, 0, .60)", strokeWidth: 1,
					height: 1, stretch: go.GraphObject.Horizontal,
					margin: new go.Margin(5, 0, 0, 0) // top, right, bottom, left
				  },
				  new go.Binding("visible").ofObject("SUBCOMPONENTS")  // only visible when info is expanded
				),
				
				$(go.Panel, "Vertical",
				  {
					name: "SUBCOMPONENTS", 
					stretch: go.GraphObject.Horizontal, 
					margin: 8,
					defaultAlignment: go.Spot.Left, 
					itemTemplate: subComponentsTemplate,
					visible: false
				  },
				  new go.Binding("itemArray", "subComponents") 
				
				),
				
			), // end Panel Vertical main

	); // end NodeTemplate




var customEditor = new go.HTMLInfo();
var customSelectBox = document.createElement("select");

customEditor.show = function(textBlock, diagram, tool)
 {
    console.log("textBlock.name: " + textBlock.name);
}

Your code creates an HTMLInfo but doesn’t use it anywhere, so I do not see how its show function could possibly be called.

The purpose of the HTMLInfo class is to act as a HTML alternative to an Adornment implemented in GoJS. If you aren’t referring to a HTMLInfo where there would otherwise be an Adornment, I’m not sure there is much use for an HTMLInfo.

I suggest that you just implement a click event handler on the TextBlock or Panel that is your subComponentsTemplate and implement the DOM-modifying behavior that you want. Don’t bother with HTMLInfo.

Ok - I’ve implemented the “click”-function with in the subComponentTemplate as you suggest (it works successfull).
If my understanding is correct it is not possible to anchor the “select”-Box inside the Panel , because there is no html-parent element inside the panel available. Is this correct?

var subComponentsTemplate =
	$(go.Panel, "Horizontal",
		
		$(go.Picture,
			{ 
			margin: new go.Margin(5, 5, 5, 3) , // top, right, bottom, left, 
			desiredSize: new go.Size(30, 30), source: "./ProcessArchitect_files/LogoFesto.png"},
			new go.Binding("source", "iconRequiredComponent"),
		),
		
		$(go.TextBlock, "available components",
			{ 	name: "MAPPEDINSTANCE",
				editable: true,
				font: "8pt Verdana, sans-serif" ,
				choices: ['One', 'Two', 'Three', 'Four'],
				
				click: function(e, obj)
				{	
					console.log("obj: " + obj.name);
					
					var componentList = document.createElement("select");
					console.log("choices len: " + obj.choices.length);
					for (var i = 0; i < obj.choices.length; i++)
					{
						var op = document.createElement("option");
						op.text = obj.choices[i];
						op.value = obj.choices[i];
						componentList.add(op, null);
					}
					
					var loc = obj.getDocumentPoint(go.Spot.TopLeft);
					var pos = e.diagram.transformDocToView(loc);
					componentList.style.left = pos.x + "px";
					componentList.style.top  = pos.y + "px";
					componentList.style.position = 'absolute';
					componentList.style.zIndex = 100; // place it in front of the Diagram
					e.diagram.div.appendChild(componentList);
				}
			},
			
		)
	);

Yes, that’s true, but now I see what I think you are trying to do. Doesn’t this demonstrate what you want?
Text Editing Examples
It makes use of:
https://gojs.net/latest/extensions/TextEditorSelectBox.js

Yes that’s my use case - nearly !
A select-box should be available after clicking in one of the TextBlocks ‚click me‘ and not in the main panel above.
image

If define the “textEditingTool.defaultTextEditor” in the 'subComponentsTemplate" TextBlock the following error occur:
image

It is possible to call a selectBox from a TextBlock?
Thanks in advance!

	myWorkspace =
	$(go.Diagram, "divWorkspace",
		{ 	maxSelectionCount: 1, 
			"undoManager.isEnabled": true,
            // it works if the line below is uncommented, but that's not my use case
			//"textEditingTool.defaultTextEditor": window.TextEditorSelectBox, 
		}
	);

	var subComponentsTemplate =
	$(go.Panel, "Horizontal",
						
		$(go.Picture,
			{ 
			margin: new go.Margin(5, 5, 3, 3) ,
			desiredSize: new go.Size(30, 30), source: "./ProcessArchitect_files/LogoFesto.png"},
			new go.Binding("source", "iconRequiredComponent"),
		),
	
		$(go.TextBlock, "click me",
			{ 	name: "MAPPEDINSTANCE",
				font: "8pt Verdana, sans-serif" ,
				isMultiline: true,
                 // here is my use case but it doesn't work (error in the screenshot)
				"textEditingTool.defaultTextEditor": window.TextEditorSelectBox, // defined in textEditorSelectBox.js
				},
		)
	);

...

There’s only one instance of TextEditingTool. Like all Tools, they are associated with the Diagram, not with any specific GraphObject, and are managed by the ToolManager, which is accessed via the Diagram.toolManager property. That is why you can only set a TextEditingTool property when initializing the Diagram – that syntax is specially handled by make ($ here).

But you can control which text editor the TextEditingTool should use for each TextBlock: set or bind TextBlock.textEditor, TextBlock | GoJS API.

The sample demonstrates this. As it says:

TextBlocks can also have their own custom editors that override the TextEditingTool’s editor, by setting TextBlock.textEditor. The last TextBlock in each node has its own custom editor that consists of an HTML div with several radio buttons. This editor will change the text as soon as an option is selected.

Ok - I understand the principle. I set the property ‘textEditor’ in my code - but nothing occur. What is missing in my code?

var subComponentsTemplate =
	$(go.Panel, "Horizontal",
						
		$(go.Picture,
			{ 
			margin: new go.Margin(5, 5, 3, 3) , // top, right, bottom, left, 
			desiredSize: new go.Size(30, 30), source: "./ProcessArchitect_files/LogoFesto.png"},
			new go.Binding("source", "iconRequiredComponent"),
		),
	
		$(go.TextBlock, "click me",
			{ 	name: "MAPPEDINSTANCE",
				font: "8pt Verdana, sans-serif" ,
				isMultiline: true,
				textEditor: window.TextEditorSelectBox, // !!!
				choices: ['One', 'Two', 'Three', 'Four'],
			},
		)
	);

I just tried it, and it worked exactly as I expected. Your TextBlock declaration looks reasonable, so I can only guess that you haven’t loaded the extension “extensions/TextBlockSelectBox.js” or “extensionsJSM/TextBlockSelectBox.js”.

What’s the value of window.TextEditorSelectBox?

The console.log output about the textEditor:

image

In my html-file I load the required js-Files:

<script src="go-debug.js"> </script>
<script src="TextEditorSelectBox.js"></script>
...

It’s surprising that the SelectBox occurs when the diagram use the TextEditorSelectBox !
In the nested ‘subComponentsTemplate’ it doesn’t work !

myWorkspace =
	$(go.Diagram, "divWorkspace",
		{ 	maxSelectionCount: 1, 
			"undoManager.isEnabled": true,
            //  successfull - but not my use case
			"textEditingTool.defaultTextEditor": window.TextEditorSelectBox, 
		}
	);

	var subComponentsTemplate =
	$(go.Panel, "Horizontal",
						
		$(go.Picture,
			{ 
			margin: new go.Margin(5, 5, 3, 3) , 
			desiredSize: new go.Size(30, 30), source: "./ProcessArchitect_files/LogoFesto.png"},
			new go.Binding("source", "iconRequiredComponent"),
		),
	
		$(go.TextBlock, "click me",
			{ 	name: "MAPPEDINSTANCE",
				font: "8pt Verdana, sans-serif" ,
				isMultiline: true,

                // use case but it doesn't work
				textEditor: window.TextEditorSelectBox, 
				choices: ['One', 'Two', 'Three', 'Four'],
				
				click: function(e, obj)
				{
					console.log( "textEditor: " + obj.textEditor);
					console.log( "window.TextEditorSelectBox: " + window.TextEditorSelectBox);
				}
			},
		)
	);

Your subComponentsTemplate looks OK to me, so I cannot explain that. Here’s what I tried, and it works well:

<!DOCTYPE html>
<html>
<head>
  <title>Minimal GoJS Sample</title>
  <!-- Copyright 1998-2022 by Northwoods Software Corporation. -->
</head>
<body>
  <div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:400px"></div>
  <textarea id="mySavedModel" style="width:100%;height:250px"></textarea>

  <script src="https://unpkg.com/gojs"></script>
  <script src="https://unpkg.com/gojs/extensions/TextEditorSelectBox.js"></script>
  <script id="code">
const $ = go.GraphObject.make;

const myDiagram =
  $(go.Diagram, "myDiagramDiv",
    {
      "undoManager.isEnabled": true,
      "ModelChanged": e => {     // just for demonstration purposes,
        if (e.isTransactionFinished) {  // show the model data in the page's TextArea
          document.getElementById("mySavedModel").textContent = e.model.toJson();
        }
      }
    });

myDiagram.nodeTemplate =
  $(go.Node, "Auto",
    $(go.Shape, "Rectangle",
      { strokeWidth: 0, fill: "white" },
      new go.Binding("fill", "color")),
    $(go.Panel, "Vertical",
      $(go.TextBlock,
        { font: "bold 18px sans-serif", margin: 8 },
        new go.Binding("text").makeTwoWay()),
      $(go.Panel, "Vertical",
        new go.Binding("itemArray", "items"),
        {
          stretch: go.GraphObject.Horizontal,
          defaultStretch: go.GraphObject.Horizontal,
          itemTemplate:
            $(go.Panel, "Auto",
              $(go.Shape,
                { strokeWidth: 0 },
                new go.Binding("fill", "color")),
              $(go.TextBlock,
                {
                  editable: true,
                  isMultiline: false,
                  textEditor: window.TextEditorSelectBox,
                  choices: ["one", "two", "three", "four", "five"]
                },
                new go.Binding("text").makeTwoWay())
            )
        }
      )
    )
  );

myDiagram.model = new go.GraphLinksModel(
[
  {
    text: "Delta", color: "#00BFA5",
    items: [
      { text: "one", color: "magenta" },
      { text: "two", color: "orange" },
      { text: "three", color: "lime" }
    ]
  }
]);
  </script>
</body>
</html>

Thanks for your respone - your code is running also on my system !
I’ll have a look about this problem maybe in the future. Currently it is not mandatory for me to use the TextEditorSelectBox . It was only nice to have - in the evaluation period, which ends next week!
I hope my company is enabling me to get a license in the next time.
Thanks for your well support!