I am trying to insert some formatted text in Cocoa using the accessibility API. This is what I did:
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);
I always get the error kAXErrorIllegalArgument (-25201) . If I try to insert plain text, then it works fine.
So, does anyone know how to insert formatted text using the accessibility API?
source share