I want to set adornment always visible.
I’m assuming this is a GoJS question, because your previous question was about GoJS. So I have recategorized this topic from GoDiagram to GoJS.
Instead of always showing an Adornment, why not just extend your Node (or Link?) template(s) to show what you wanted to show in Adornments?
The whole point of Adornments is that they can be created on demand to only be shown when needed. And their creation is virtualized, so there’s no overhead in either space or time for Adornments on Parts that are completely off-screen.
Because I want to resize or reshape my shape by the first click. I don’t want to select then after do resize or reshape.
That would require overriding Tool.updateAdornments on the particular tools that you care about. Here’s an override for ResizingTool, as a Diagram initialization:
$(go.Diagram, ...,
{
"resizingTool.updateAdornments":
function(part) {
if (part === null || part instanceof Link) return; // can't resize links
if (this.diagram !== null && !this.diagram.isReadOnly) {
var resizeObj = part.resizeObject;
if (resizeObj !== null && part.canResize() && part.actualBounds.isReal() && part.isVisible() && resizeObj.actualBounds.isReal() && resizeObj.isVisibleObject()) {
var adornment = part.findAdornment(this.name);
if (adornment === null || adornment.adornedObject !== resizeObj) {
adornment = this.makeAdornment(resizeObj);
}
if (adornment !== null) {
var angle = resizeObj.getDocumentAngle();
adornment.angle = angle;
var loc = resizeObj.getDocumentPoint(adornment.locationSpot);
var sc = resizeObj.getDocumentScale();
adornment.location = loc;
var place = adornment.placeholder;
if (place !== null) {
var ns = resizeObj.naturalBounds;
place.desiredSize = new go.Size(ns.width * sc, ns.height * sc);
}
this.updateResizeHandles(adornment, angle); // fix up any cursors to point the right way
part.addAdornment(this.name, adornment);
return;
}
}
}
part.removeAdornment(this.name);
}
})
For the GeometryReshapingTool at https://gojs.net/latest/extensions/GeometryReshapingTool.js, you can modify or override the updateAdornments method not to check for part.isSelected
.
Thank you very much. I removed part.isSelected. And all works fine.