Author Topic: UIBUttonMessage onRelease/onClick Problem  (Read 3874 times)

basil_11

  • Guest
UIBUttonMessage onRelease/onClick Problem
« on: July 17, 2013, 02:43:13 AM »
hi,
im new in NGUI and im a bit confused with the execution hierarchy in UIBUttonMessage onRelease/Onclick

onRelease goes first then the onClick.

Im using UIButonMessage for my buttons to execute functions in my COntroller Script
and I want to prevent clicking buttons at the same time

void OnClickFunction ()
{
      if (!GUIManager.canTrigger)  {
         Debug.Log ("can't click");
         return;
   }
   GUIManager.canTrigger = false;
}

Problem: I dont have way to put the GUIManager.canTrigger = TRUE

im trying the onRelease but onRelease is Executed first :(

can someOne give me advices thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIBUttonMessage onRelease/onClick Problem
« Reply #1 on: July 17, 2013, 04:24:28 AM »
I'd advise rethinking your approach. The order of NGUI's events is not meant to be changed. A click is pressing and releasing the mouse button on the same object. Unless the button is released, there is no click. Instead of doing what you're doing, set your global "canTrigger" flag somewhere in a remote script, and just check it like you do, but don't set it to 'false' in the click function. Instead set it to 'false' in the same place you set it to 'true' to begin with.

Or better yet -- when you can't click on a button, disable it (UIButton.isEnabled).

basil_11

  • Guest
Re: UIBUttonMessage onRelease/onClick Problem
« Reply #2 on: July 17, 2013, 04:46:09 AM »
Hi Aren,

Thanks for the advice,

I can appreciate it more if there are some sort of code attached :)

I'm a bit confused on how I handle clicking events properly just like I said in the issue