Author Topic: Button Question  (Read 1562 times)

dwmurp

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Button Question
« 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!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Button Question
« Reply #1 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. }

dwmurp

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Button Question
« Reply #2 on: February 08, 2014, 02:25:31 PM »
Makes sense. I was trying to make this harder than it was. Thank you very much!