How to move a Text Display Object programmatically

I have a Text Display Object named “TextDisplayObject”. I can obtain its position using this code:

message rectanglesizestr(objectinfo("rectangle","TextDisplayObject"))

which gives result like 317,736,204,325.

How do I change its location? I would prefer to specify the new position of its top left corner but the rectangletweak( function is acceptable if it’s the only way to do it.

Check out the moveobjects statement.

I think this will move the object “TextDisplayObject” to the upper left corner.

moveobjects "TextDisplayObject", "=", 

Thanks Gary - I don’t know why I couldn’t see that in the list when I searched for ‘object’.

And thanks Tom - but I think you’ve misread my requirement - I want to specify the location of the top left, not move it to the top left.

I would probably use the changeobject statement for this, with the rectangletweak( function. This is exactly the sort of application these were designed for.

let topleft = 100
let topright = 200
changeobject "TextDisplayObject",
        "x", topleft,
        "y", topright)

For some reason Discourse doesn’t understand this link to the rectangletweak( function. But it’s in the Help file.

I think this will work.You didn’t say how you were going to specify the new position, but you could do it with a mouse click. I assumed you could put a large white rectangle behind the other objects on the form, and put this code in the procedure for the rectangle, then an option-click will move the object to the spot where you clicked:

if optionclick()
moveobjects "TextDisplayObject", "=", v(xytoxy(info("click"),"s","f"))-rtop(objectinfo("rectangle","TextDisplayObject")), 

You need the xytoxy function because mouse clicks are returned in screen relative coordinates but form relative coordinates are needed. I see Jim’s solution but don’t see why one is preferable.

I’m currently using this:

changeobject "TextDisplayObject","$LocationX", val(array(Location,2,",")) + val(array(Location,4,",")) + 5
changeobject "TextDisplayObject","$LocationY", val(array(Location,1,","))

but your code looks much better.

Did some further investigating and that was a goof on my part. The URL’s aren’t supposed to have ( in it to avoid this type of problem.

It’s purely personal preference. Under the hood, the moveobjects statement is a custom statement that uses changeobjects and the rectangleadjust( function to do the actual work.