如何激活没有标题栏的窗口

发布于 2024-12-18 07:22:10 字数 96 浏览 1 评论 0原文

我可以发送消息 makeKeyAndOrderFront: 来激活窗口。但是,如果我将其发送到没有标题栏的窗口,则不会使其处于活动状态。有没有办法让没有标题栏的窗口处于活动状态?

I can send the message makeKeyAndOrderFront: to make a window active. However, if I send this to a window without a title bar, it doesnt make it active. Is there any way to make a window without a title bar active?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

耀眼的星火 2024-12-25 07:22:10

您需要覆盖 -canBecomeKeyWindow 在您的 NSWindow 子类中返回YES

根据文档:

如果出现这种情况,则尝试使该窗口成为关键窗口将被放弃
方法返回NO。 NSWindow 实现返回 YES 如果
窗口有标题栏或调整大小栏,否则没有。

You need to override -canBecomeKeyWindow in your NSWindow subclass to return YES.

As per the docs:

Attempts to make the window the key window are abandoned if this
method returns NO. The NSWindow implementation returns YES if the
window has a title bar or a resize bar, or NO otherwise.

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