使 NSSplitView 的分隔线不可拖动并且不显示拖动光标

发布于 2024-09-30 16:10:32 字数 500 浏览 5 评论 0原文

我有一个带有三个子视图的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风追烟花雨 2024-10-07 16:10:32

我知道这个问题已经得到解答一段时间了,但提供的答案不符合我的需要。

委托方法 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 return NSZeroRect no drag cursor will ever appear, regardless of your setup in splitView:constrainMaxCoordinate:ofSubviewAt: and splitView:constrainMinCoordinate:ofSubviewAt:.

鹿童谣 2024-10-07 16:10:32

尝试使用 splitView:constrainMaxCooperative:ofSubviewAt:splitView:constrainMinCooperative:ofSubviewAt: 而不是 splitView:constrainSplitPosition:ofSubviewAt:

前两个方法在用户拖动鼠标时调用一次,它们为 NSSplitView 提供了足够的信息,以了解如何在拖动过程中更改光标。

当用户拖动分割器时,后者会被重复调用,因此 NSSplitView 没有足够的信息来知道您每次返回一个常量值,因此无法更改光标。

Try using splitView:constrainMaxCoordinate:ofSubviewAt: and splitView:constrainMinCoordinate:ofSubviewAt: instead of splitView: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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文