• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSSliders that "partly" snap to tick marks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSliders that "partly" snap to tick marks


  • Subject: Re: NSSliders that "partly" snap to tick marks
  • From: "Marc Wan" <email@hidden>
  • Date: Fri, 6 Apr 2007 10:03:32 +0800

On 4/5/07, Bob Clark <email@hidden> wrote:
I can't see a way in Interface Builder to tell an NSSlider to snap to
tick marks only if the indicator is close to a tick mark, and slide
"continuously" if it's not really close to a tick mark.

i had the same question, and as far as i could tell, there is no magic checkbox for this. so, i just implemented it myself. i was super lazy and didn't even bother subclassing the slider, simply because it was like 5 lines of code.

 in my sliderValueChanged method, i just added:

   /**
    * try to do a little "snapping" to make it a little cooler.
    */
   float tickIncr = [sender maxValue] / ([sender numberOfTickMarks] - 1);
   if (fabs(val - ((int)((val + 0.5) / tickIncr) * tickIncr)) < 0.5)
   {
       val = roundf(val);
       [sender setFloatValue: val];
   }


my slider does 0 to 30.0, with ticks every 5.0, so i just have it snap within 0.5 of one of those ticks.

 m.


--Bob

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSSliders that "partly" snap to tick marks (From: Bob Clark <email@hidden>)

  • Prev by Date: Re: Cocoa equivalent of subclassing a REALbasic Canvas?
  • Next by Date: Re: Cocoa wrapper for pcap library?
  • Previous by thread: NSSliders that "partly" snap to tick marks
  • Next by thread: Core Data Document-Based App
  • Index(es):
    • Date
    • Thread