如何使NSView移动到所有NSView的前面 [英] How do I make an NSView move to the front of all NSViews
问题描述
我有一个超级视图,其中有2个子视图。
这些子视图是重叠的。
I have a super view, which has 2 subviews. These subviews are overlapped.
每当我从菜单中选择一个视图时,相应的视图应该成为前视图并处理操作。
即它应该是最前面的子视图。
Whenever i choose a view from a menu, corresponding view should become the front view and handle actions. i.e., it should be the front most subview.
acceptsFirstResponder
辞职所有工作正常。
但是鼠标按下事件被发送到设置的最顶层子视图。
acceptsFirstResponder
resigns all work fine.
But the mouse down events are sent to the topmost sub view which was set.
尊敬的,
Dhana
Regards, Dhana
code> [viewToBeMadeForemost removeFromSuperview];
[self addSubview:viewToBeMadeForemost located:NSWindowAbove relativeTo:nil];
[viewToBeMadeForemost removeFromSuperview];
[self addSubview:viewToBeMadeForemost positioned:NSWindowAbove relativeTo:nil];
根据此方法的文档,当您使用 relativeTo:nil
视图是在其上面(或下面,
NSWindowBelow
)添加的所有兄弟姐妹。
Per the documentation for this method, when you use relativeTo:nil
the view is added above (or below, with NSWindowBelow
) all of its siblings.
这篇关于如何使NSView移动到所有NSView的前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!