Cocoa / OSX - NSTextField不响应单击以在标题栏隐藏时开始文本编辑 [英] Cocoa/OSX - NSTextField not responding to click for text editing to begin when titlebar is hidden

查看:1081
本文介绍了Cocoa / OSX - NSTextField不响应单击以在标题栏隐藏时开始文本编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NSTextField在我的窗口(添加了IB)与一个隐藏的标题栏,但当我点击它,当应用程序运行时,它不响应或在其字段中放置一个光标。有什么我做错了吗?

I have a NSTextField in my window (added with IB) with a hidden title bar but when I click on it when the app is running, it does not respond or place a cursor in its field. Is there anything I am doing wrong? it is setup in the most standard way possible, an editable textfield on a window.

感谢。

推荐答案

创建一个继承自NSWindow的自定义类,并将其设置为InterfaceBuilder中的NSWindow对象。然后覆盖以下方法:

Create a custom class that inherits from NSWindow, and set it as the NSWindow Object in InterfaceBuilder. Then override the following methods:

//
// canBecomeKeyWindow
//
// Overrides the default to allow a borderless window to be the key window.
//
- (BOOL)canBecomeKeyWindow
{
    return YES;
}

//
// canBecomeMainWindow
//
// Overrides the default to allow a borderless window to be the main window.
//
- (BOOL)canBecomeMainWindow
{
    return YES;
}

这篇关于Cocoa / OSX - NSTextField不响应单击以在标题栏隐藏时开始文本编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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