Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: dlewis on August 08, 2012, 08:53:14 PM

Title: OnSelected bug?
Post by: dlewis on August 08, 2012, 08:53:14 PM
I've just started to investigate the events for NGUI for mobile and I noticed that OnSelected doesn't work the way I expected it to (and what the comments seem to imply).

The way I understand it is that OnSelected should fire when there is a mouse down and mouse up (or touch) on the same object. However the code works so that it will only fire OnSelect you mouse down and up on a new object from the previous one, so if you keep clicking on the same object it will only fire the first time till you click on a different object.

I was able to fix this by changing a few lines so that it doesn't require the selection to be different from the previous to fire the event.

Starting from line 985 of UICamera.cs
  1. // If the button/touch was released on the same object, consider it a click and select it
  2. if (currentTouch.pressed == currentTouch.current)
  3. {
  4.         Notify(currentTouch.pressed, "OnSelect", true);
  5.         mSel = currentTouch.pressed;
  6.  
  7.     // Rest of the code is the same
  8.  

I also noticed that OnSelected is with a capital O where as the other events are onPressed (small o), not a bit issue though.
Title: Re: OnSelected bug?
Post by: ArenMook on August 08, 2012, 10:00:24 PM
Small 'o' is for callbacks. Big 'O' is for SendMessage functions. They're two different things. Select happens when you press on something. It is not un-selected until you press on something else.