简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM