I spent some time looking at your slider, and also comparing it to how it works on the iPad/iPhone. I just uploaded my changes to your code. You did a great job on this, and it was fun to tweak things to make it a bit closer to Apple's version.
You can download mine here:
Here's what I changed:
if isvariable is set to true, I get an error:
...rona SampleCode/Interface/OffOnSliderTest/slider.lua:82: attempt to call global 'TapComplete' (a nil value)
[C]: in function 'TapComplete'
...rona SampleCode/Interface/OffOnSliderTest/slider.lua:82: in function <...rona SampleCode/Interface/OffOnSliderTest/slider.lua:57>
?: in function <?:186>
so, what is TapComplete? I ended up commenting out that line:
--TapComplete( nil )
I created a light grey screen background with anti-aliased cutouts so the sliders fit a lot better.
I changed it so that if you move the slider at all from its starting point, it goes to the other endpoint. This seems to match Apple's sliders on the iPhone (rather than only doing that if you moved it at least half-way across).
I added an "over" state to the button portion of the slider, but only if you click on the button part. (to match Apple's)
If you click on the button part and then drag off the button, the highlight goes off when you're 10 pixels outside (adjustable) and comes back when you're in range.
Fixed it so if you click outside the viewport, the button no longer moves (before, clicking to the left or right, depending on where the slider image was, would trigger it to move)
Previously, if you click on a slider, event.target.isFocus is true. After that, you were able to swipe in from off the button and onto it and it would still react (but only the button you last clicked on). Now fixed.
I also ended up changing the initial caps of the function names to lower case... seems that's the standard that others are following here. I also added a capital letter in the middle some of the names to make them easier to read.
I'm sure there's probably a much more elegant way to code all the things I changed... I'm still learning, so just figured if it works, that's good for now.
uid: 9905 topic_id: 3276 reply_id: 10745