问题标签 [nstextfield]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
objective-c - NSTextField 绑定导致 EXC_BAD_ACCESS
我有一个 NSTextField,它绑定到我包含在我的笔尖中的一个对象中的一个 int。当对象更改其 int 时,文本字段也会随之变化,一切看起来都很好。
但是,当我尝试手动更改它时,只要我按下一个键,程序就会崩溃。它甚至没有进入我的 setter 方法,它只是崩溃了
它甚至不在我的任何代码中......大概是我把绑定弄错了,但我能做些什么让它像这样的段错误?
ETA:崩溃的堆栈帧:
我确实有一个从 子类化的文档类NSDocument
,并且文本字段绑定到该文档对象的一个字段,但我不确定为什么这很重要。
objective-c - Focus NSAlert 配件
我有一个 NSAlert 项,它使用 NSTextField 作为附件项来提供类似提示的对话框。我唯一的问题是,当警报运行时,文本字段没有聚焦。我试图寻找一种方法来改变 NSAlert 的第一响应者,但一无所获。有没有办法在 NSAlert 中轻松聚焦附件项目?
cocoa - 如何将菜单项添加到 NSTextField 的上下文菜单
我试图覆盖简单的 NSView 方法:
但它不起作用。它永远不会被调用。
cocoa - 找出字段编辑器的 NSTextField
我用
提供我自己的字段编辑器,以便我可以显示自定义上下文菜单。这可行,但是在我的字段编辑器的“menuForEvent:”方法中,我如何找到它附加到哪个 NSTextField?
编辑:好的,我发现我在 TextView 中通过
问题是 - 这是一个好的解决方案还是一个黑客。我必须跳过 _NSKeyboardFocusClipView 类的内部响应程序,所以我担心这可能不适用于未来的 Cocoa 版本。
cocoa - NSTextField 中的文本格式
我有一个图形应用程序,它使用 NSTextField 实例进行就地文本编辑,这个功能是很久以前添加的,我从来没有理由去检查它,但是,我最近收到了一个报告:文本文件不允许文本格式化。格式 -> 文本菜单子项全部禁用,因此无法设置文本项的段落。
问题:我应该如何设置 NSTextField 来支持段落编辑?我确信它之前确实有效,因为我有一些带有格式化文本的项目,并且 NSTextField 自从应用程序诞生以来就在那里。我错过了系统/XCode 更新的内容吗?
我的 NSTextField 是多行的,可编辑的,允许编辑文本属性。
cocoa - 验证 NSTextField 中的十进制最大值/最小值
首先,我必须在没有 IB 和没有像 KVO 这样的高级 Objective-C 技术的情况下做到这一点。
我的问题来自一个简单的事实,即我找不到获取文本字段的全新字符串值的方法。
我尝试使用委托功能:
但这并不仅仅给我替换字符串而不是我需要验证的完整字符串。我可以稍后使用文本
我发现
但是当我接到这个电话时已经很晚了,最后一个文本字段的内容已经消失了。那么处理这个问题的最佳方法是什么?
是的,我确实读过将 NSTextField 绑定到 NSNumber,但它让我不知道如何解决我的问题。
我只需要一个简单的“- (BOOL)acceptNewValue(NSString string)”测试函数。为什么 Cocoa 的一切都变得如此复杂,它开始感觉像 MFC。
cocoa - Can't successfully register undo from NSTextField
I have a simple document-based application that simply creates a custom XML file. It uses an Outline View to navigate the XML document. When an item in the Outline View is selected a custom view is displayed as a sub view of the document view that allows the user to enter in data. On one of the views has a NSTextField. It has its "Allows Undo" flag set. I tested to ensure the undoManager is called on the NSDocument when the editing is completed. So the control seems to be bouncing through the First Responder as it should.
In the IBAction I use the ActionName so it will display correctly in the menu. Now here is the problem. Not only is the ActionName not displayed in the menu, but clicking undo doesn't reverse the action taken on the NSTextField but the action registered just before it. Is there something I overlooked when setting up undo with NSTextField?
(IBAction)textFieldChanged:(id)sender{
...some code here...
[[self undoManager]setActionName:@"Change Text"];
}
Thanks in advance, Rob
cocoa - 我需要做一些 NSTextFieldCell 的高级文本样式
首先,我只需要在文本上使用一些背景颜色。就像 F 脚本浏览器中的标题一样
设置 [cell setBackgroundColor: [NSColor blueColor]]; 不仅为文本着色整个单元格空间。我也需要带下划线和删除线的文字。为了使事情变得可读,我最后想更改样式项目上选择的颜色(前景/背景)。
我可以用默认的 NSTextFieldCell 做到这一点吗?
cocoa - 如果 NSTextfield 为空,则禁用/启用 NSButton
我是可可的新手。我的应用程序中有一个按钮和一个 textField。我希望在文本字段为空时禁用该按钮,并在用户键入内容时启用该按钮。
有什么要开始的吗?Interface Builder中的任何“魔术”绑定?
谢谢
[编辑]
我尝试将 appDelegate 设置为 NSTextfield 的委托并添加了此方法(myTextfield 和 myButton 是 IBOutlets):
但是什么也没有发生...
cocoa - NSManagedObjectContext 保存导致 NSTextField 失去焦点
这是我在我的应用程序中看到的一个非常奇怪的问题。我有一个 NSTextField 绑定到 NSManagedObject 的属性,但是每当保存对象时,文本字段就会失去焦点。我不断更新绑定的值,所以这远非理想。
以前有没有人见过这样的事情,并且(希望)找到了解决方案?