Sto cercando di inserire del testo formattato in Cocoa usando l'API di accessibilità. Questo è quello che ho fatto:Inserimento di testo formattato utilizzando l'API di accessibilità in 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'
L'errore ottengo sempre è kAXErrorIllegalArgument (-25201)
. Se provo a inserire testo non formattato, allora funziona bene.
Quindi, qualcuno sa come inserire un testo formattato utilizzando l'API di accessibilità?
qual è il tuo kAXValueDescriptionAttribute? –
@JonasSchafft kAXValueDescriptionAttribute è una costante. – ashokgelal
@kamaldeepsinghbhatia Sì, sto cercando di inserire il formato "ciao, mondo" – ashokgelal