Author Topic: UITooltip current state  (Read 5777 times)

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
UITooltip current state
« on: December 06, 2013, 12:52:24 PM »
Hi Aren,
Would it be possible to add some accessor to the UITooltip class to query if it is currently showing?

Something like this
  1. /// <summary>
  2.         /// returns the showing state of the tooltip
  3.         /// </summary>
  4.  
  5.         static public bool Showing
  6.         {
  7.                 get
  8.                 {
  9.                         if (mInstance != null)
  10.                         {
  11.                                 return mInstance.mCurrent!=0;
  12.                         }
  13.                         return false;
  14.                 }
  15.         }

or something similar

would be helpful in avoiding a OnClick event when displaying a tooltip (using OnPress) on mobile devices

thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITooltip current state
« Reply #1 on: December 06, 2013, 02:24:11 PM »
Sure, but the correct function would be
  1.         /// <summary>
  2.         /// Whether the tooltip is currently visible.
  3.         /// </summary>
  4.  
  5.         static public bool isVisible { get { return (mInstance != null && mInstance.mTarget == 1f); } }

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: UITooltip current state
« Reply #2 on: December 06, 2013, 03:33:22 PM »
thanks

I think tho that the tooltip will still be visible unless mCurrent == 0, ie.  0 < mCurrent < 1  would be the fade in/out of the tooltip which means its still visible on screen

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITooltip current state
« Reply #3 on: December 07, 2013, 12:58:41 AM »
Yup, but it would be in the process of fading out.

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: UITooltip current state
« Reply #4 on: December 07, 2013, 04:13:33 AM »
okay, can we have a method in that case to query the state of fading aswell then? ie isTransitioning

thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITooltip current state
« Reply #5 on: December 07, 2013, 03:11:06 PM »
You have the code, you can add whatever you want :)

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: UITooltip current state
« Reply #6 on: December 09, 2013, 06:05:39 AM »
sorry to be a PITA, modifying the NGUI library is not something I want to do, it means I need to redo the changes every time I upgrade the NGUI project (which has been a many times recently!), originally I thought would just extend the UITooltip interface ( ie. void ExtentedFunc(this UITooltip tooltip) { ... }) but I think this isn't possible with the singleton implementation. If mInstance was public, then I'd I could use extensions np.

thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITooltip current state
« Reply #7 on: December 09, 2013, 07:49:36 AM »
Fair enough. I've gone ahead and made all the variables protected and functions virtual, so you can derive from it and add your own custom behaviour.

That said though, the UITooltip script is pretty small, and isn't needed by NGUI. You could create a copy of the class and modify what you need, then use that instead of UITooltip.

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: UITooltip current state
« Reply #8 on: December 09, 2013, 07:51:21 AM »
I'll do that, thanks