Author Topic: Any way to tell if a UISlider is currently being dragged?  (Read 4213 times)

tydygunn

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 20
    • View Profile
Any way to tell if a UISlider is currently being dragged?
« on: October 13, 2015, 01:28:52 PM »
Hiya! NGUI's a lifesaver!

I'm building a scene with camera movement where the user can click and drag the mouse to rotate the camera. I've got it so when the mouse cursor is hovering above a UI collider it'll disable camera movement, but I'm having an issue with sliders. When you click and drag a slider, the cursor can move off the slider's collider area, therefore the camera's movement is allowed again even though the user is still dragging my UIScrollView's slider.

Do you have a technique I could use to check if a slider is in use? I've tried simply checking if UISlider.current != null, but that doesn't seem to be working. UISlider.current.isActiveAndEnabled doesn't work either, but I'm not 100% certain of the purpose of that bool so I didn't expect it to work in the first place. The slider is attached to a UIScrollView, so maybe I could check if that scroll view is being moved? I'm not sure how I'd do that.

Thanks for any advice you could give! Currently using NGUI 3.8.2.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Any way to tell if a UISlider is currently being dragged?
« Reply #1 on: October 14, 2015, 08:34:39 AM »
UICamera.currentTouch.pressed tells you what you pressed it on. Don't just check for what it's currently over. Check for what it's pressed on first.