使 NSSplitView 的分隔线不可拖动并且不显示拖动光标
我有一个带有三个子视图的 NSSplitView (NO UISplitView(Controller)!!)。现在,对于最后一个分隔线(索引 1
),我希望分隔线不显示拖动光标(两个箭头相互指向)。我用它来停止拖动,但光标仍然显示:
- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex {
if (dividerIndex == 1) {
return [splitView frame].size.width - 161;
}
}
请注意,我只想隐藏索引 1
处分隔线的光标。谁能帮助我吗?谢谢。 :)
不,我不想使用 BWToolkit。
I have an NSSplitView (NO UISplitView(Controller)!!) with three subviews. Now, for the last divider (index 1
), I want the divider to not show the dragging cursor (two arrows pointing out of eachother). I have this to stop the dragging, but the cursor is still showing up:
- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex {
if (dividerIndex == 1) {
return [splitView frame].size.width - 161;
}
}
Note that I only want to hide the cursor for the divider at index 1
. Can anyone help me? Thanks. :)
No, I don't want to use BWToolkit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这个问题已经得到解答一段时间了,但提供的答案不符合我的需要。
委托方法
splitView: effectiveRect:forDrawnRect:ofDividerAtIndex:
允许您设置拖动分隔线的有效矩形。如果您返回 NSZeroRect,则无论您在 splitView:constrainMaxCoordinate:ofSubviewAt: 和 splitView:constrainMinCooperative:ofSubviewAt: 中进行何种设置,都不会出现拖动光标。I know this has been answered for a while, but the supplied answer did not suit my needs.
The delegate method
splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:
allows you to set the effective rectangle for dragging the divider. If you returnNSZeroRect
no drag cursor will ever appear, regardless of your setup insplitView:constrainMaxCoordinate:ofSubviewAt:
andsplitView:constrainMinCoordinate:ofSubviewAt:
.尝试使用
splitView:constrainMaxCooperative:ofSubviewAt:
和splitView:constrainMinCooperative:ofSubviewAt:
而不是splitView:constrainSplitPosition:ofSubviewAt:
。前两个方法在用户拖动鼠标时调用一次,它们为 NSSplitView 提供了足够的信息,以了解如何在拖动过程中更改光标。
当用户拖动分割器时,后者会被重复调用,因此 NSSplitView 没有足够的信息来知道您每次返回一个常量值,因此无法更改光标。
Try using
splitView:constrainMaxCoordinate:ofSubviewAt:
andsplitView:constrainMinCoordinate:ofSubviewAt:
instead ofsplitView:constrainSplitPosition:ofSubviewAt:
.The former two methods are called once as the user drags the mouse and they give enough information for NSSplitView to know how to change the cursor during the drag.
The latter is called repeatedly as the user drags the splitter, so NSSplitView doesn't have enough information to know that you're returning a constant value each time and therefore can't change the cursor.