以编程方式更改为其他空间 (MacOSX)
我正在制作一个自定义窗口(带有 NSBorderlessWindowMask 的 NSWindow) 到目前为止,我已经能够处理拖动、调整大小、cmd+单击,甚至在允许的情况下通过双击进行小型化(请参阅 此处),所以我的窗口尽可能类似于一个普通的 NSWindow。
然而,当我将窗口拖到屏幕的一角时,用户会期望将该窗口移动到下一个空间。 (如果您在“系统首选项”>“公开和空间”>“空间”>“启用空间”中启用了空间)
我想知道如何以编程方式更改为其他空间并将窗口移动到那里?
I am making a customised window (a NSWindow with NSBorderlessWindowMask) So far I have been able to handle dragging, resizing, cmd+click and even miniaturize with double click if allowed (see here) so my window resembles as much as possible to a normal NSWindow.
However when I drag my window to the corner of my screen the user will expect to move that window to the next space. (In case you have Spaces enabled in "SystemPreferences" > "Expose and Spaces" > "Spaces" > "Enable Spaces")
I wonder how can I change to other space programmatically and move my window there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,没有公共 API 允许您执行此操作,但如果您愿意使用私有 API,这是可能的。看一下 CGPSrivate.h 你就会请
注意,使用此私有 API 会导致您的应用程序被 Apple 的 Mac App Store 拒绝。
Unfortunately there's no public API which allows you to do this, but if you're willing to use the Private API it's possible. Take a look at CGSPrivate.h and you'll see you can make a call like this:
Note that using this private API will cause your app to be rejected from Apple's Mac App Store though.
最后我找到了解决方案。
我无法以编程方式更改为某个空间,但如果
[window setMovableByWindowBackground:YES]
完成,我可以使我的窗口表现得像其他非 NSBorderlessWindowMask 一样。这是这个问题的最终目的:)这里写下了解决方案(有一些细节),因为这个问题似乎比较旧(或者可能是这个问题的重复? )
有吗使自定义 NSWindow 与 Spaces 一起使用的方法
Finally I found a solution.
I can't change to a certain space programmatically but I can make my window behave like other non
NSBorderlessWindowMask
if[window setMovableByWindowBackground:YES]
is done. That was the final purpose of this question :)The solution is written (with some detail) here because that question seems to be older (or maybe a duplicate of this question?)
Is there a way to make a custom NSWindow work with Spaces