【发布时间】:2012-05-08 04:15:42
【问题描述】:
是否可以在 TextEdit 中检索所选文本的字体名称(通过 ObjC 或 Carbon)? 我尝试了这段代码,但“值”为空:
AXUIElementRef systemWideElement = AXUIElementCreateSystemWide();
AXUIElementRef focussedElement = NULL;
AXError error = AXUIElementCopyAttributeValue(systemWideElement,
kAXFocusedUIElementAttribute, (CFTypeRef*)&focussedElement);
CFTypeRef value;
AXUIElementCopyAttributeValue(focussedElement, kAXFontTextAttribute, &value);
谢谢。
【问题讨论】:
-
AXUIElementCopyAttributeValue返回后focussedElement的值是多少? -
AXUIElementCopyAttributeValue返回后focussedElement的值有效(非空)。
标签: macos macos-carbon textedit