Author Topic: Missing NGUI OnMouseUp and 'OnHoverWhileOnPress' Events  (Read 6828 times)

Cawas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
  • fucking programmer
    • View Profile
Missing NGUI OnMouseUp and 'OnHoverWhileOnPress' Events
« on: September 19, 2013, 04:21:09 PM »
edit: since nobody answered yet, I fixed it myself. The original intent of posting this was still to get a review and ask for alternatives, so not much really change...

Using NGUI 2.7.0 here.

About the NGUI Events, I've missed 2 kind of events:

- OnMouseUp : because OnPress(false) is actually equivalent to OnMouseUpAsButton
- OnHover while OnPress : no idea why it was not implemented

Since I couldn't find a good way around it, I've implemented them on UICamera.

For the first part, it was easy. I've added a whole line to 1164, right after if (unpressed), and a whole new convention for a equivalent to OnMouseUp, which works both for Mouse and Tap on tablets:

  1.                         Notify(currentTouch.current, "OnPressUp", null);
  2.  

After I did that, just recently, ArenMook gave me another way of doing it: UICamera Sticky Press. But I still prefer this one. :P

For the second part, it was a lot tougher (to make it work on tablets)! I've basically changed 2 lines (923 and 952) under the method ProcessMouse replacing !isPressed by (useTouch || !isPressed) - basically saying "if use mouse and use touch, consider is hover regardless of is pressed". I think it makes sense, and it worked.

This is how my UICamera:923 looks now:

  1.                 // The button was released over a different object -- remove the highlight from the previous
  2.                 if (useMouse && (useTouch || !isPressed) && mHover != null && mHover != mMouse[0].current)
  3.  

But it did not work on mobile / tablets. So I got stuck without a solution for hours... Finally, I got to some solution I'm not completely happy with, only because I think it's modifying too many lines (about 5). Basically I added a "or" useTouch verification in some places where there was only a useMouse and it was dealing with hover, some how. I think it's too much to try and show here.

Should I post the whole file here? Is there another way to achieving all this?
« Last Edit: November 18, 2013, 07:45:17 AM by Cawas »

NGUIJeffS

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Missing NGUI OnMouseUp and 'OnHoverWhileOnPress' Events
« Reply #1 on: January 23, 2014, 04:29:53 PM »
Hi, Yes, please post if it is not too much trouble. I'm looking for a way (on Mobile) to "show the user"  that their finger is over "hovering above" an object (ie, a Button or DragDrop item or popupList menu etc...). If anyone has any great ideas please post. I'm looking at using ray cast. It that insane or am I on the right track? or is there something in NGUI that I'm not aware of?