Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

oneeyeman

macrumors newbie
Original poster
Nov 14, 2012
16
0
Hi, ALL,
I am a Software Developer who tried to learn Cocoa programming.

Currently I am trying to implement the NSSlider with ticks and labels. My task is to place the labels to be aligned with ticks.

Now unfortunately it looks like I will have to create a labels by hand as Cocoa does not provide a way to create a labels for NSSlider. I would also like to have a NSSlider window to be a parent of the labels so that the NSSlider itself will manage the positioning/sizing of the labels.

What is the easiest way of doing so? Everywhere I look labels are made as children of the dialog.panel where the NSSlider is located. However it makes it to have more work.

Is it possible what I'd like to do? Is it in compliance with Cocoa UI guidelines? Will I have to change the z-order of the windows and bring the labels to the top in order for them to be visible? If yes, how?
 
Looking at the docs, the reference for NSSlider says the UI is actually implemented by NSSliderCell. Did you look at that class? There are some options in the default implementation. If you don't like that implementation, the reference docs for NSSliderCell tells you what methods to override if you want to sublcass it and create a modified one.
 
Hi, mfram,
I am trying to learn Cocoa programming and this stumbles me.
Here is my issue:

Using XCode RAD tool I can create an NSSlider in the dialog/panel and then I can place the labels on that same dialog/panel, which means that both nSSlider and the labels will have the same parent - this same dialog/panel.

Now what I'm after is create an NSSlider and then create labels which have the NSSlder as their parent. Therefore I don't want to use any graphical tool and do it in the code. Now obviously I'd like the labels to be properly positioned and visible.
I would also like to be able to operate on this NSSlider as a composite control - hence the need to ahve labels with different parent.

Now is this possible what I'm asking? Can I get some sample code I can use?

Thank you.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.