reshapeComponent displays at wrong position

(Windows 8, Version 7.8.4)

I’m having an odd bug with the system.gui.reshapeComponent call.

I have two containers (A and B) that are being positioned using reshapeComponent based on their parent container’s © dimensions. The components are re-positioned correctly unless you resize C indirectly . For example, if C has layout anchors on all four sides, resizing C’s parent component will indirectly resize C. In my case, C’s parent is the Root Container.

When the reshapeComponent function is called with an indirectly-resized C, A and B are positioned with weird offsets every time. Sizes seem to be correct, it’s the locations that are incorrect.

These weird offsets can be corrected by going back to edit mode and manually moving ANY component (via either arrow keys or dragging it) in any direction. Suddenly everything will snap to the proper position. After that the reshapeComponent function calls will work as expected until C is indirectly resized again.

The last part is only testable in the designer because you cannot manually re-position elements in published versions, but the positioning errors that occur when resizing the root container in the designer are the same as resizing the window in a published version.

I have tried calling the java functions to revalidate and/or repaint the components

I have included a SSCCE with the code I’m using contained in a custom function inside the “Doc Split Container” component, called from the “Multi-State Button” component.

Here is the code for the custom function in side the “Doc Split Container” component:

[code]def reshapeComponents(self, vertical):
doc1 = self.getComponent(“Doc 1 Container”)
doc2 = self.getComponent(“Doc 2 Container”)
size = self.getSize()

#Resize Doc 1/2 Container depending on whether layout is Vertical or Horizontal
#ERROR: Components always seem to end up the proper SIZE but not always at the correct LOCATION
if not vertical:

def reshapeDocs(dc):
	#Resize/position the components within Doc 1/2 Container
	label = dc.getComponent("Path Label")
	doc = dc.getComponent("Document Viewer")
	size2 = dc.getSize()

#Invoke the reshapeDocs calls later to ensure the sizes of the parent
#  components have properly updated in the UI thread
def later():

Is this a bug with Ignition or is there a workaround that I can put into my script?

Hi Ted,

Have you tried using the system.gui.transform function instead?


Hi Nick,
Yes it is the same for reshapeComponent() and for transform().

I have found that it happens inside of templates as well but it may only apply to the width. For example, if you create a button inside a template and on actionPerformed you transform it to its own coordinates and dimensions, it works fine unless the width of the template instance is altered. Narrower template widths make the button shrink each time. Wider templates make the button grow each time. This is independent of the coordinate space parameter as well.

This was tested with multiple layout anchors and even using LayoutManager calls to remove and replace anchors before and after the transform calls. I didn’t see the same behavior applied to the height or position in this situation, though it did seem to apply in the initial SSCCE that I posted using containers rather than templates.