Author Topic: How can I alter onPress and onClick functions?  (Read 3345 times)

hellwalker

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
How can I alter onPress and onClick functions?
« on: April 17, 2014, 08:57:02 PM »
Hey  :D

I was wondering if it is possible to alter button functions.
I'm building a simple joystick with gui and for arrows I want to simulate Input.GetButton behavior with NGUI-s OnPress, and it works, but the change I want to make is that now OnPress will set isDown to false only when you stop holding mouse or finger and I want it to set isDown to false when mouse or finger moves outside the button. So If I touch and hold my finger on arrow buttons and then move my finger (or mouse) completely off the button it is still "pressed" and I want to change this.

For OnClick it waits for you to sort of click and release to register clicking, sort of like ButtonUP, and I want for click to register during initial clicking like Unity's  ButtonDown.

If you could point me to where the script for this functions is within NGUI or if there is way to achieve my task without changing those any tips on that would be awesome too.

Thanks in advance!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How can I alter onPress and onClick functions?
« Reply #1 on: April 18, 2014, 04:22:21 PM »
EventDelegate.Set(button.onClick, YourFunction);
EventDelegate.Add(button.onClick, YourFunction);
EventDelegate.Remove(button.onClick, YourFunction);