2016-02-12 6 views
5

Ich versuche, formatierten Text in Cocoa mit Accessibility API einzufügen. Dies ist, was ich getan habe:Formatierten Text mit Accessibility API in Cocoa einfügen?

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' 

Der Fehler habe ich immer ist kAXErrorIllegalArgument (-25201). Wenn ich versuche, nicht formatierten Text einzufügen, funktioniert es einwandfrei.

Also weiß jemand, wie man einen formatierten Text mit Accessibility API einfügen?

+0

Was ist Ihr KAXValueDescriptionAttribute? –

+0

@JonasSchafft kAXValueDescriptionAttribute ist eine Konstante. – ashokgelal

+0

@kamaldeepsinghbhatia Ja, ich versuche, formatiert "Hallo, Welt" einzufügen – ashokgelal

Antwort

0

Ich glaube nicht, dass Sie die Beschreibung, Wert oder Titel auf eine attributierte Zeichenfolge festlegen können. Vielleicht können Sie die attributierte Zeichenfolge mit abrufen, aber es gibt keine AXUIElementSetParameterizedAttributeValue.

Verwandte Themen