Jim Rubenstein
Jim Rubenstein

Reputation: 6930

Setting the position/width of an NSSlider inside an NSMenuItem

I've got an NSMenu attached to an NSStatusItem, and inside that NSMenu I have a NSMenuItem for which I've set the view property to an NSSlider object. That works (it got me what I was after) almost.

The result looks like this:

NSSlider in an NSMenu as an NSMenuItem.view http://dl.dropbox.com/u/91596/Screenshots/k8tl.png

The problem is that I'd like the slider to line up with the menu items above it, so it doesn't look so friggin terrible.

I can't find anything in the apple documentation that says anything about being able to set the position of an NSSlider so I assume I'm going to have to wing it by drawing it myself.

Is that a correct assumption? If so, what are some class references/suggested reading links for achieving that result? Or, am I going about this wrong?

While I'm at it - I had to drag the slider in the UI builder to the desired width I wanted - is there any way to programmatically set the width of the slider so it fills up the desired space inside the menu?

Thanks, sorry of these are noob questions - I'm pretty new to ObjC programming.

Upvotes: 2

Views: 899

Answers (1)

Evadne Wu
Evadne Wu

Reputation: 3200

First make your own NSView. Next, put your NSSlider in that view. If you need special spacing, adjust the slider in the container view. Or, maybe, twiddle in Interface Builder.

Upvotes: 2

Related Questions