使NSSplitView的分隔符不可拖动,并且不显示拖动光标 [英] Make the divider of an NSSplitView undraggable and don't show the dragging cursor

查看:531
本文介绍了使NSSplitView的分隔符不可拖动,并且不显示拖动光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NSSplitView(没有UISplitView(控制器)!! )与三个子视图。现在,对于最后一个分隔符(索引 1 ),我想分隔符不显示拖动光标(两个箭头指向彼此)。我有这个停止拖动,但光标仍然显示:

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;
  }
}

注意,我只想隐藏分隔符在索引 1 。谁能帮助我?谢谢。 :)

Note that I only want to hide the cursor for the divider at index 1. Can anyone help me? Thanks. :)

不,我不想使用BWToolkit。

推荐答案

尝试使用 splitView:constrainMaxCoordinate:ofSubviewAt: :constrainMinCoordinate:ofSubviewAt:而不是 splitView:constrainSplitPosition:ofSubviewAt:

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

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.

因为用户拖动分隔符,所以NSSplitView没有足够的信息,知道你每次返回一个常量值,因此不能更改光标。

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.

这篇关于使NSSplitView的分隔符不可拖动,并且不显示拖动光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆