Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 在Cocoa中使用辅助功能API插入格式化文本?_Objective C_Cocoa_Accessibility_Nsattributedstring - Fatal编程技术网

Objective c 在Cocoa中使用辅助功能API插入格式化文本?

Objective c 在Cocoa中使用辅助功能API插入格式化文本?,objective-c,cocoa,accessibility,nsattributedstring,Objective C,Cocoa,Accessibility,Nsattributedstring,我正在尝试使用可访问性API在Cocoa中插入一些格式化文本。这就是我所做的: NSFont *font = [NSFont fontWithName:@"Arial" size:14.0]; NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; NSAttributedString *attrString = [[NSAttributedStrin

我正在尝试使用可访问性API在Cocoa中插入一些格式化文本。这就是我所做的:

NSFont *font = [NSFont fontWithName:@"Arial" size:14.0];
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"hello, world" attributes:attrsDictionary];
AXError error = AXUIElementSetAttributeValue(element, kAXValueDescriptionAttribute, attrString);
// element is an instance of 'AXUIElementRef' with role 'AXTextArea'
我经常遇到的错误是
kAXErrorIllegalArgument(-25201)
。如果我尝试插入未格式化的文本,那么效果很好


那么,有人知道如何使用可访问性API插入格式化文本吗?

我认为您无法将描述、值或标题设置为属性字符串。也许您可以使用
AXUIElementCopyParameterizedAttributeValue
获取属性字符串,但是没有
AXUIElementSetParameterizedAttributeValue

您的kAXValueDescriptionAttribute是什么?@JonasSchafft kAXValueDescriptionAttribute是一个常量。@KamalDeepingHBhatia是的,我正在尝试插入格式化的“hello,world”