|
|
|
It is currently Wed May 22, 2013 12:35 pm
|
View unanswered posts | View active topics | View unsolved topics
|
Page 1 of 1
|
[ 6 posts ] |
|
| Author |
Message |
|
vahterto
Captain
Joined: Thu Apr 15, 2010 8:22 am Posts: 98 Location: Tampere, Finland
|
 z order in runtime
Hi
Is it possible to change graphics components z order in runtime? Like X and Y.
Br Tommi
|
| Mon Aug 06, 2012 9:04 am |
|
 |
|
James.Lorenz
Moderator
Joined: Mon Jun 04, 2012 8:53 am Posts: 405
|
 Re: z order in runtime
Yes, it is possible. The root container of a window is a Java Container, so it can use setComponentZOrder(). Here is an example of a script which changes the z order of components on a window called "Main Window": Code: cont = system.gui.getWindow('Main Window').getRootContainer()
comp = cont.getComponent("Multi-State Indicator") comp1 = cont.getComponent("Moving Analog Indicator") comp2 = cont.getComponent("LED Display")
cont.setComponentZOrder(comp,0) cont.setComponentZOrder(comp1,1) cont.setComponentZOrder(comp2,2)
_________________ James Lorenz QA/Build Engineer Inductive Automation
|
| Mon Aug 06, 2012 9:21 am |
|
 |
|
vahterto
Captain
Joined: Thu Apr 15, 2010 8:22 am Posts: 98 Location: Tampere, Finland
|
 Re: z order in runtime
Thanks ! I was sure that there is solution to do this .
BTW: If I just want to change component which is top of others; Do I have to change all components z order?
Br Tommi
|
| Mon Aug 06, 2012 10:12 am |
|
 |
|
James.Lorenz
Moderator
Joined: Mon Jun 04, 2012 8:53 am Posts: 405
|
 Re: z order in runtime
Yes, you would have to change the z order of every component. Changing the order of one component will change at least the order of one other component, since no two components can be on the same "level". So if you put a component on top (i.e., level "0"), that component on top can no longer be at level 0, it must be changed to a different level.
_________________ James Lorenz QA/Build Engineer Inductive Automation
|
| Mon Aug 06, 2012 10:22 am |
|
 |
|
vahterto
Captain
Joined: Thu Apr 15, 2010 8:22 am Posts: 98 Location: Tampere, Finland
|
 Re: z order in runtime
Hi
Some reason this script does not seems to be working in "runtime".
cont = system.gui.getWindow('Left').getRootContainer()
comp = cont.getComponent("Rectangle") comp1 = cont.getComponent("Rectangle 1")
cont.setComponentZOrder(comp,0) cont.setComponentZOrder(comp1,1)
It works only in designer and there also so that I have to toggle design/runtime mode between actions? Do I need some kind of refresh action??
|
| Mon Aug 06, 2012 11:16 pm |
|
 |
|
James.Lorenz
Moderator
Joined: Mon Jun 04, 2012 8:53 am Posts: 405
|
 Re: z order in runtime
Yes, you would need to refresh the window, I forgot to add that in to the script. Calling a repaint() on the container where the components are located should do the trick. Add this to the end of your script:
_________________ James Lorenz QA/Build Engineer Inductive Automation
|
| Tue Aug 07, 2012 7:20 am |
|
 |
|
|
Page 1 of 1
|
[ 6 posts ] |
|
Who is online |
Users browsing this forum: jamess and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|