5

I'm trying to insert some formatted text in Cocoa using accessibility API. This is what I've done:

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'

The error I always get is kAXErrorIllegalArgument (-25201). If I try to insert non-formatted text then it works fine.

So, does anyone know how to insert a formatted text using accessibility API?

ashokgelal
  • 80,002
  • 26
  • 71
  • 84

1 Answers1

0

I don't think you can set the description, value or title to an attributed string. Maybe you can get the attributed string with AXUIElementCopyParameterizedAttributeValue but there is no AXUIElementSetParameterizedAttributeValue.

Willeke
  • 14,578
  • 4
  • 19
  • 47