eliotfowler / EFCircularSlider

An extensible circular slider for iOS applications
http://eliotfowler.github.io/EFCircularSlider/
MIT License
998 stars 161 forks source link

Check whether point lies within circle rather than frame rectangle for touches #14

Closed fatuhoku closed 10 years ago

fatuhoku commented 10 years ago

This is a fix for #13.

This pull request makes sure that sliders act correctly when placed closely together in a concentric arrangement, like on the time picker demo application.

The problem was that touches were being registered by the slider even though it was outside of the circle, yet within its frame rectangle.

By implementing a containment check inside pointInside:withEvent:, such touch events are not captured; Cocoa passes touch events DOWN view hierarchy to views that sit beneath the slider — which is another slider, in our case.

Subsequently beginTrackingWithTouch:withEvent: is only invoked for touches within the circle (with a fat-finger allowance of +11 points — seems to work alright!), which is what we want!

eliotfowler commented 10 years ago

Awesome, thanks!