Copy link to clipboard
Copied
I'm trying to move fields using the rect property, but it doesn't seem to want to move multiple fields. I was trying to come up with a loop that would use an array of all child fields, but I'm not getting what I want. Is this even possible?
var oParent = this.getField("my.field.name");
var getStr = 'this.getField("';
var aChildren = oParent.getArray();
for(i in aChildren) {
var fldName = getStr + aChildren[i].name + '")';
var bRect;
var aRect = bRect + i;
aRect = fldName.rect;
aRect[0] -= 24;
aRect[2] -= 24;
fldName.rect = aRect;
}
I have several variations of the code above. This is one of them. The console was returning [object field]my.field.name.children but not this.getField("my.field.name.children);
It also doesn't seem to care about the rect property. I've also tried the simple coding for rect and am not able to get parent fields to perform rect. The console returns InValidGetError: Get not possible, invalid or unknown.
I want all fields affected to do the same thing regardless of original xyxy coordinates. I was assuming that I couldn't utilize the rect property on multiple hierarchal fields at the same time, but then I wondered if I could get an array of all children, return the object name, then add .rect to each iteration and perform the same rect each time it goes through the loop...
It's certainly possible, but your code doesn't make sense, especially the part where you're trying to access the fields.
If they are all a part of a group that is called "my.field.name" then all you need to do is this:
var oParent = this.getField("my.field.name");
var aChildren = oParent.getArray();
for (var i in aChildren) {
var f = aChildren[i];
var aRect = f.rect;
aRect[0] -= 24;
aRect[2] -= 24;
f.rect = aRect;
}
Copy link to clipboard
Copied
fldName.rect
will not work because fldName is not a field object.
Copy link to clipboard
Copied
It's certainly possible, but your code doesn't make sense, especially the part where you're trying to access the fields.
If they are all a part of a group that is called "my.field.name" then all you need to do is this:
var oParent = this.getField("my.field.name");
var aChildren = oParent.getArray();
for (var i in aChildren) {
var f = aChildren[i];
var aRect = f.rect;
aRect[0] -= 24;
aRect[2] -= 24;
f.rect = aRect;
}
Copy link to clipboard
Copied
Thank you. I couldn't get it to work in the file I was working in, but it works perfectly in a test page I created. I don't know what the issue was, but I kept getting the InvalidGetError message. It was a similar script to others I had tried.