# Binding/Animating size/position within container

**URL:** <https://forum.inductiveautomation.com/t/binding-animating-size-position-within-container/19985>\
**Category:** Ignition\
**Created:** [October 4, 2018, 11:29pm UTC](https://forum.inductiveautomation.com/t/binding-animating-size-position-within-container/19985 "2018-10-04T23:29:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [October 4, 2018, 11:29pm UTC](https://forum.inductiveautomation.com/t/binding-animating-size-position-within-container/19985/1 "2018-10-04T23:29:59Z")

</div>

Hi all,

Setting up a popup to control a motor, and my motor UDT has a parameter which defines whether it’s reversible or not. If not, I show just two buttons; Start and Stop. If it is reversible, I display three: Start Forward, Stop, Start Reverse.

What I’d ideally like is for the buttons to take up the same amount of space whether there are two or three. So, if there are two buttons, they’d either re-size to take up the full width, or at least re-position slightly to stay centred. Is it possible to do this dynamically? In any other SCADA package I’d just make 5 buttons and switch between them using visibility animations as necessary, but I’d like to think there’s a neater way of doing it in Ignition!

---

<div class="post-metadata">

**Author:** ![nick.schuetz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nick.schuetz/32/6160_2.png) [@nick.schuetz](https://forum.inductiveautomation.com/u/nick.schuetz)\
**Post date:** [October 4, 2018, 11:46pm UTC](https://forum.inductiveautomation.com/t/binding-animating-size-position-within-container/19985/2 "2018-10-04T23:46:11Z")

</div>

You can use system.gui.transform() to resize or move the buttons you want. You would probably do this in a visionWindowOpened script. If you just want to move them to center, you could move them with _object_.x =newX.

Something like that.

---

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [October 5, 2018, 1:06am UTC](https://forum.inductiveautomation.com/t/binding-animating-size-position-within-container/19985/3 "2018-10-05T01:06:57Z")

</div>

Thanks! That’s exactly what I was looking for.

---

<div class="post-metadata">

**Author:** ![a.ansari](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@a.ansari](https://forum.inductiveautomation.com/u/a.ansari)\
**Post date:** [November 29, 2018, 10:51am UTC](https://forum.inductiveautomation.com/t/binding-animating-size-position-within-container/19985/4 "2018-11-29T10:51:20Z")

</div>

Hi All,  
Looks like this solution would apply to my situation as well. Although I am not sure how I would hook up the script to be called. Where is the visionWindowOpened event on the window? And what if I have a template I would like to the same for?

Would appreciate an example of how to call the script. Thanks.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [November 29, 2018, 3:53pm UTC](https://forum.inductiveautomation.com/t/binding-animating-size-position-within-container/19985/5 "2018-11-29T15:53:05Z")

</div>

> [@a.ansari](#):
>
> Where is the visionWindowOpened event on the window?

Right-click on window in **Project Browser** tree and choose **Scripting...** (window must be open). Expand the **visionWindow** folder in the Component Scripting window that pops up to find **visionWindowOpened** event and tap on the **Script Editor** tab.

---

<div class="post-metadata">

**Author:** ![a.ansari](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@a.ansari](https://forum.inductiveautomation.com/u/a.ansari)\
**Post date:** [November 29, 2018, 6:08pm UTC](https://forum.inductiveautomation.com/t/binding-animating-size-position-within-container/19985/6 "2018-11-29T18:08:09Z")

</div>

Thanks, that worked!
