Rectangle Tool or Symbol reshape problem

Dear Inductive Team,

We had a requirement where we need to change the Position, Size of a Rectangle Tool / Symbol (from Symbol Factory) based on User data entry. To start with: We placed one tool / Symbol and one Numeric text Field for new width entry; change width by keeping the tool’s / Symbol’s X, Y positions and height as it has initially. When we used following code, it is taking 0,0 as X,Y positions and complete container height as its height.

[code]# Get required variables.
vShape = event.source.parent.getComponent(‘Rectangle’)
vX = vShape.x
vY = vShape.y
vHeight = vShape.height

Get new width from Numeric Text Field.

vWidth = event.source.parent.getComponent(‘Numeric Text Field’).intValue

Check whether entered width is greater than ‘0’ or not.

if vWidth > 0:
# Reshape component to new Width.
system.gui.reshapeComponent(vShape, vX, vY, vWidth, vHeight)
system.gui.errorBox(‘Width should be greater than 0.’, ‘Invalid width’)[/code]
Another observation is, When we see X, Y values for the tool / Symbol in the Designer it shows one value; In event handler it is showing different value (tested through error box).

Waiting for your valuable suggestions.

The problem is that the component’s x and y may change in the runtime due to the component’s layout. So there is the x and y that you saved in the designer and a relative x and y that you get in the runtime. The x and y you see on the rectangle is the relative x and y. The system.gui.reshapeComponent expects you to work from the designer’s x and y. It will perform the translation necessary to convert it to the relative x and y due to the layout.

So, you should hard code the x and y initially rather than getting it from the component. You can also not use the system function and just set the components relX, relY, relHeight, relWidth directly.

Thank you Travis.

We got your point. We will try with different approach for achieving our requirement.