[英]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. 我有一个
NSMenu
附加到NSStatusItem
,并且在NSMenu
内有一个NSMenuItem
,我已将其view
属性设置为NSSlider
对象。 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 NSMenu中的NSSlider作为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. 我在Apple文档中找不到任何有关设置
NSSlider
位置的NSSlider
因此我认为我将不得不自己绘制它。
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? 在执行此操作时-我不得不将UI生成器中的滑块拖动到所需的所需宽度-是否有任何方法以编程方式设置滑块的宽度,以使其填充菜单内所需的空间?
Thanks, sorry of these are noob questions - I'm pretty new to ObjC programming. 谢谢,抱歉,这是新手问题-我对ObjC编程很陌生。
First make your own NSView
. 首先创建自己的
NSView
。 Next, put your NSSlider
in that view. 接下来,将
NSSlider
放在该视图中。 If you need special spacing, adjust the slider in the container view. 如果需要特殊间距,请在容器视图中调整滑块。 Or, maybe, twiddle in Interface Builder.
或者,也许是在Interface Builder中旋转。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.