Has anyone had success with moving templates on a window?
I have tried a number of approaches as follows:
Template canvas
Placing a template canvas on a window in the required location, or even spanning the entire window, allows moving the template. However we found it is impossible to locate the template accurately wrt graphical objects / components that are not templates (ie not on the canvas).
system.gui.transform() allows movement of templates, but again the coordinates seem to be unmanageable over window coordinates. Extending this approach, we used invisible lines as reverence x & y axes, and used transform() to move the template wrt to these axes. Again, we found this unreliable as templates moved to unexpected locations.
Thanks Phil
Yes, that works, thanks
However, my screen is rather complex with many components. To keep the screen appearance consistent ALL components would need to be anchored. This results in unacceptable layout.
What I find confusing is that I can use an expression binding on the âxâ property of a ânormalâ component and this works fine, but it doesnât work on a template
When I had a template anchored to the bottom and right edges of a window, I had to negate some arguments in system.gui.transform().
The following code excerpt gets a buttonâs current coordinates, then âmovesâ the button to the coordinates that were just obtained. By all accounts, it looks like pointless code that wouldnât do anything. But if the button is anchored to the right edge of the screen, this code snippet actually changes the x coordinate to the negative of whatever it was before. (E.g. If the button was at (40, 120) this would move it to (-40,120), which is off the screen.)
The following code, meanwhile, seems like it would move the button to a negative x coordinate. But when it runs on a button anchored to the right edge of the screen, the button does not move at all:
oldBtnY = btn.getY()
oldBtnX = btn.getX()
finalBtnY = oldBtnY
finalBtnX = -oldBtnX # This needs to be negative because of the button being anchored to the right side of the screen.
system.gui.transform(component = btn, newX = finalBtnX, newY = finalBtnY)
Somebody whoâs more competent with java might know a clever way to convert the coordinates automatically, but I stuck with manually programming negations in where I needed them.