Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: dwmurp on February 08, 2014, 02:01:36 PM

Title: Button Question
Post by: dwmurp on February 08, 2014, 02:01:36 PM
Hi all,

I bought NGUI a while back and have had great success with it. I haven't had any issue figuring out anything I had issues with on my own or from these forums so this is my first post.

I'm experiencing a behavior with UIButton that I would like to change and am having issues figuring out how to do so.

When I hover over a button things work as normal. Clicking Enter does nothing (which is as I want.) Once I click the button with the mouse, subsequent presses of the Enter key cause the button to click. I would like to change this behavior, but am having issues figuring out how to do so.

It's probably something easy I'm overlooking, but I've been trying to figure it out and failing so if anyone can provide some advice I would be most appreciative.

Thanks!
Title: Re: Button Question
Post by: ArenMook on February 08, 2014, 02:09:22 PM
This happens because the button obtains OnSelect focus when you click it. You can remove the focus at any time by using a function like this:
  1. void OnPress (bool isPressed)
  2. {
  3.     if (!isPressed) UICamera.selectedObject = null;
  4. }
Title: Re: Button Question
Post by: dwmurp on February 08, 2014, 02:25:31 PM
Makes sense. I was trying to make this harder than it was. Thank you very much!