5
アクセシビリティAPIを使用して、書式設定されたテキストをCocoaに挿入しようとしています。これは私がやったことです:私は常に取得アクセシビリティ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を使用して書式設定されたテキストを挿入する方法を知っている人はいますか?
あなたのkAXValueDescriptionAttributeは何ですか? –
@ JonasSchafft kAXValueDescriptionAttributeは定数です。 – ashokgelal
@kamaldeepsinghbhatiaはい、私は書式設定された "hello、world"を挿入しようとしています。 – ashokgelal