Author Topic: Advice for adding OpenOn.Hover to UIPopUpList?  (Read 5807 times)

sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
Advice for adding OpenOn.Hover to UIPopUpList?
« on: January 27, 2015, 03:13:37 PM »
I've got the start of it easily enough, adding to the enum and:
  1. void OnHover(bool isOver)
  2.         {
  3.                 if (openOn == OpenOn.Hover && isOver)
  4.                         Show();
  5.                 else if (openOn == OpenOn.Hover && !isOver)
  6.                         Close();
  7.         }
But the problem is once you try to go over the options it closes... so how would I make it detect being over the popup options as well, and only closing if the mouse is off both the original button and the dropdown's background? I imagine it involves adding a collider to the background sprite and some other reference to see if it's hovered over as well, but I'm not sure how that'd work since I don't think it'd call the UIPopUp.cs OnHover method?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Advice for adding OpenOn.Hover to UIPopUpList?
« Reply #1 on: January 28, 2015, 02:11:04 AM »
Open on hover like you're doing now, but don't close it on hover. Instead subscribe to UICamera.onHover and keep an eye on what's underneath the mouse there. Close it when you need it.