Positioning components with 'x' and 'y' properties and system.gui.transform()

Hi all,

So I am trying to create a plot of the timing of various devices during one of our system’s runs. Start time and duration can vary among several different devices, so we have in the past listed them as horizontal rectangles of various lengths, with length proportional to on-duration.

Rectangles are very easy. They have an ‘x’ and ‘width’ component, which I can bind to start and end-start respectively.

The problem is labels. I would like the labels to float near the rectangles, for continuity with the old gui. The issue is their x and width properties are not settable or bindable, and if I try to modify them with event.source.getComponent(‘label’).x I get an error that they are read only.

So, I guess for starters, it would be nice if you could position labels and text fields etc the same way shapes can be. I can position them using the vision main toolbar, so their properties are accessible and settable, just not by the designer in a programmatic way

Secondly, I tried using system.gui.transform, which works, in a sense. The issue is it positions objects relative to the container, which in this case would be the root container, or window. Depending on window size and aspect ratio, the objects located using the main toolbar, or through setting their ‘x’ and 'width properties are referenced entirely differently than the objects positioned with system.gui.transform. All objects are currently set ‘relative’ in their layout constraints.

The problem seems to be, I set a rectangle to be, say 40 pixels from the left, and based on how the screen is scaled, that can be 60 or 80 or 120. So when my script reads the x value as 40, and transforms the label, it ends up at 40 FAR away from where it needs to be.

Anyway around this? I could try using Anchored layout constraints, but don’t really like that look. Plus I’m not sure it would even work.

You should be using system.gui.transform, but probably need to tell it to use designer coordinates, so that relative layout is applied after your coordinates/dimensions.

Integer coordSpace - The coordinate space to use. When the default screen coordinates are used, the given size and position are absolute, as they appear in the client at runtime. When Designer Coordinates are used, the given size and position are pre-runtime adjusted values, as they would appear in the Designer. See system.gui constants for valid arguments. [optional]

GAH! What a bonehead mistake. RTFMA. Thanks, Phil. This is precisely the issue.