我使用了-setContentborderThickness:forEdge:在窗口上使渐变看起来正确,并确保表格从正确的位置滑出.
然而,什么不工作,是拖动窗口.如果我点击并拖动实际上是标题栏的区域,它会起作用,但是由于标题栏渐变会溢出(潜在/通常为空)的标签栏,所以轻轻点击太低,当您尝试拖动时感觉真的很沮丧并实现窗口不动.
我注意到NSToolbar,同时在标题栏下占用大致相同的空间,允许在光标在其上方时拖动窗口.如何实现这一点?
谢谢.
解决方法 我发现这个 here:-(voID)mouseDown:(NSEvent *)theEvent { NSRect windowFrame = [[self window] frame]; initialLocation = [NSEvent mouseLocation]; initialLocation.x -= windowFrame.origin.x; initialLocation.y -= windowFrame.origin.y;}- (voID)mouseDragged:(NSEvent *)theEvent { NSPoint currentLocation; NSPoint newOrigin; NSRect screenFrame = [[NSScreen mainScreen] frame]; NSRect windowFrame = [self frame]; currentLocation = [NSEvent mouseLocation]; newOrigin.x = currentLocation.x - initialLocation.x; newOrigin.y = currentLocation.y - initialLocation.y; // Don't let window get dragged up under the menu bar if( (newOrigin.y+windowFrame.size.height) > (screenFrame.origin.y+screenFrame.size.height) ){ newOrigin.y=screenFrame.origin.y + (screenFrame.size.height-windowFrame.size.height); } //go ahead and move the window to the new location [[self window] setFrameOrigin:newOrigin];}
它工作正常,虽然我不是100%肯定我做的正确.到目前为止,我发现了一个错误,就是如果拖动开始在子视图(一个选项卡本身)中,然后进入超级视图(标签栏).窗户跳了起来一些-hitTest:魔术,或者甚至可能使mouseUp上的initialLocation无效可能会解决这个问题.
总结以上是内存溢出为你收集整理的可可 – 允许点击并拖动视图来拖动窗口本身?全部内容,希望文章能够帮你解决可可 – 允许点击并拖动视图来拖动窗口本身?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)