# How to make a toggle switch in mel?

**URL:** https://forum.highend3d.com/t/how-to-make-a-toggle-switch-in-mel/4712
**Category:** Maya
**Tags:** mel
**Created:** [January 10, 2004, 5:09pm UTC](https://forum.highend3d.com/t/how-to-make-a-toggle-switch-in-mel/4712 "2004-01-10T17:09:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![diamondx](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@diamondx](https://forum.highend3d.com/u/diamondx)
#### Post date: [January 10, 2004, 5:09pm UTC](https://forum.highend3d.com/t/how-to-make-a-toggle-switch-in-mel/4712/1 "2004-01-10T17:09:36Z")

</div>

I have a Hot key for my Outliner, but I want to make it toggle ON and OFF with the Hot key. I managed to do this with many other functions, but seem to be having problems with Outliner. I usually copy mel commands onto the shelf and it works OK, but it does not seem to be working with Outliner.

Kori

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [January 10, 2004, 5:48pm UTC](https://forum.highend3d.com/t/how-to-make-a-toggle-switch-in-mel/4712/2 "2004-01-10T17:48:31Z")

</div>

i have this mapped to "o"

global proc outlinerWinToggle()  
{  
 if ( `window -exists outlinerPanel1Window` )   
 deleteUI -window outlinerPanel1Window;   
 else  
 tearOffPanel "Outliner" "outlinerPanel" false;  
}

---

<div class="post-metadata">

### Author: ![diamondx](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@diamondx](https://forum.highend3d.com/u/diamondx)
#### Post date: [January 11, 2004, 9:45pm UTC](https://forum.highend3d.com/t/how-to-make-a-toggle-switch-in-mel/4712/3 "2004-01-11T21:45:42Z")

</div>

I copy and pasted into my script editor and then dragged it on to my Shelf, but it did not work for me.

Kori

---

<div class="post-metadata">

### Author: ![dezfx](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/ce73a5/32.png) [@dezfx](https://forum.highend3d.com/u/dezfx)
#### Post date: [January 12, 2004, 2:59am UTC](https://forum.highend3d.com/t/how-to-make-a-toggle-switch-in-mel/4712/4 "2004-01-12T02:59:48Z")

</div>

You need to remove the "global proc outlinerWinToggle()" line for it to work on your shelf.

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [January 12, 2004, 8:47am UTC](https://forum.highend3d.com/t/how-to-make-a-toggle-switch-in-mel/4712/5 "2004-01-12T08:47:42Z")

</div>

Or save a global porc in a mel file that has the same name.mel in your script directory and then just paste outlinerWinToggle(); in your shelf.

Or put a call to outlinerWinToggle(); after the definition... but theres little point define it over and over again.
