# Manually active and/or hover a button

**URL:** <https://discussions.unity.com/t/manually-active-and-or-hover-a-button/512106>\
**Category:** UI\
**Tags:** IMGUI\
**Created:** [August 10, 2013, 2:31pm UTC](https://discussions.unity.com/t/manually-active-and-or-hover-a-button/512106 "2013-08-10T14:31:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enki](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@Enki](https://discussions.unity.com/u/Enki)\
**Post date:** [August 10, 2013, 2:31pm UTC](https://discussions.unity.com/t/manually-active-and-or-hover-a-button/512106/1 "2013-08-10T14:31:21Z")

</div>

I need to do something to the effect of ‘button.hover = true’ via script.  
I’ve built a menu containing buttons, but I don’t use the mouse and instead am using arrow keys.  
Anyone know how offhand?

---

<div class="post-metadata">

**Author:** ![dkozar](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dkozar/32/563194_2.png) [@dkozar](https://discussions.unity.com/u/dkozar)\
**Post date:** [August 10, 2013, 2:51pm UTC](https://discussions.unity.com/t/manually-active-and-or-hover-a-button/512106/2 "2013-08-10T14:51:47Z")

</div>

> [@Enki](#):
>
> I need to do something to the effect of ‘button.hover = true’ via script.  
> I’ve built a menu containing buttons, but I don’t use the mouse and instead am using arrow keys.  
> Anyone know how offhand?

Yes,

instead of the using GUI.Button, you’ll have to use the low-level [GUIStyle.Draw](http://docs.unity3d.com/Documentation/ScriptReference/GUIStyle.Draw.html) method and alter the 3rd (_“isHover”_) parameter.

---

<div class="post-metadata">

**Author:** ![Patico](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/patico/32/554756_2.png) [@Patico](https://discussions.unity.com/u/Patico)\
**Post date:** [August 12, 2013, 9:10am UTC](https://discussions.unity.com/t/manually-active-and-or-hover-a-button/512106/3 "2013-08-12T09:10:49Z")

</div>

> [@dkozar](#):
>
> Yes,
> 
> instead of the using GUI.Button, you’ll have to use the low-level [GUIStyle.Draw](http://docs.unity3d.com/Documentation/ScriptReference/GUIStyle.Draw.html) method and alter the 3rd (_“isHover”_) parameter.

Thanks from me too! 😉

---

<div class="post-metadata">

**Author:** ![dkozar](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dkozar/32/563194_2.png) [@dkozar](https://discussions.unity.com/u/dkozar)\
**Post date:** [August 12, 2013, 9:23am UTC](https://discussions.unity.com/t/manually-active-and-or-hover-a-button/512106/4 "2013-08-12T09:23:55Z")

</div>

> [@Patico](#):
>
> Thanks from me too! 😉

NP! 🙂  
[  
GUIStyle.Draw](http://docs.unity3d.com/Documentation/ScriptReference/GUIStyle.Draw.html) is one of the best kept secrets of Unity.

It isn’t documented at all, and this method is what [GUI.X](http://docs.unity3d.com/Documentation/ScriptReference/GUI.html) methods are wrapping around.

I personally barely use GUI.X methods at all (I’m keeping my own list of Rects for calculating mouse-overs, no need for GUI.Button to know what’s being clicked…).
