Author Topic: OnHover when Mouse Button pressed  (Read 4576 times)

MaverickDQ

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
OnHover when Mouse Button pressed
« on: November 29, 2012, 10:49:39 AM »
Is there a way to get OnHover events when mouse button is still pressed? As of now I couldn't obtain this behavior. 


Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnHover when Mouse Button pressed
« Reply #1 on: November 29, 2012, 02:01:47 PM »
Once you press down on something, it turns into a drag event, so there is no hover event until the drag stops.

mixd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: OnHover when Mouse Button pressed
« Reply #2 on: November 29, 2012, 03:21:22 PM »
If I am understanding what you are asking for... so the user clicks down on a button, then hovers "off" the button, then hovers back "on" the button while it is pressed, and you'd like to know exactly when these events happen.

Instead of "hover" I called it OnClickEnabled and OnClickDisabled:
http://www.tasharen.com/forum/index.php?topic=2416.0

Hope this is what you were looking for.

MaverickDQ

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: OnHover when Mouse Button pressed
« Reply #3 on: November 29, 2012, 04:34:25 PM »
Thanks.

Then could you advice how could I do the following:

1. I have several elements with an animation played on OnHover just to show it is active and clickable.
2. I do a mouse down over 1 element to "select" it and now move mouse over second element. Here I would like to have same animation as for OnHover. But it doesn't fire. Are there any other events fired?
3. Mouse up to "select" second element. (If I'm not wrong OnSelect will be fired for first element)

On a side note, I could check if mouse is over other elements in OnDrag doing raycast and stuff, but its more like a hack and not a robust solution IMHO.

:)

mixd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: OnHover when Mouse Button pressed
« Reply #4 on: November 30, 2012, 12:48:29 AM »
If I understand you correctly I would not advise doing this.  You shouldn't trigger a click event on an object that the user did not originally click.  This could be highly error prone and frustrating for users.

MaverickDQ

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: OnHover when Mouse Button pressed
« Reply #5 on: November 30, 2012, 05:38:43 AM »
Actually I don't intend to.

Maybe another example will help.

Suppose I need to draw a line between 2 "linked" elements. The usual way is:
1. move your mouse over first element (OnHover is animated denoting possible selection),
2. press mouse down and hold (OnDragStart for example)
3. move your mouse over second element holding the mouse down (would like to know where am I now, what element is under the mouse to animate it like in point 1)
4. you release your mouse over second element to finish the link. (event?)

Advices what event I could use are much appreciated. :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnHover when Mouse Button pressed
« Reply #6 on: November 30, 2012, 07:19:17 AM »
http://www.tasharen.com/forum/index.php?topic=2416.msg12024#msg12024

Part of 2.2.7 which is already available to Pro users. Everyone else will get it a bit later. :)

MaverickDQ

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: OnHover when Mouse Button pressed
« Reply #7 on: December 03, 2012, 04:31:45 AM »
http://www.tasharen.com/forum/index.php?topic=2416.msg12024#msg12024

Part of 2.2.7 which is already available to Pro users. Everyone else will get it a bit later. :)

Great.

Sorry for dump question, but what do you mean by Pro users? I've bought NGUI from asset store. Or, do you have a SVN for latest build?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnHover when Mouse Button pressed
« Reply #8 on: December 03, 2012, 10:43:55 AM »
Asset Store has the Standard version of NGUI priced at $95 -- which is the same as buying via PayPal directly. Professional version is an alternate method of delivery for NGUI -- it comes in the form of Git repository access, and costs $200. It's aimed more at companies than individuals as Git access means full revision history going all the way back to the first released version of NGUI, with diffs of what changed, and many other benefits for professional developers.

Since I use the same Git repository for all my work, it's always up to date and always has the absolute latest version (some call it "nightly builds"), which gives Pro users access to updates before everyone else.