Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
SetFontInfoForSelection incorrect prototype
Q: I'm trying to use the SetFontInfoForSelection API so that my text adapts to the User's choice in the Font Panel but I never receive the notifications, what's going on?
A: I'm trying to use the SetFontInfoForSelection API so that my text adapts to the User's choice in the Font Panel but I never receive the notifications, what's going on?
This is a known bug in the header file FontPanel.h. SetFontInfoForSelection is prototyped to take a HIObjectRef as its fourth and last parameter where in fact, it should be an EventTargetRef. The name of that parameter, iFPEventTarget, reflects more accurately the kind of parameter which is expected.
A simple typecast solves this problem:
Listing 1 For a window.
SetFontInfoForSelection(..., ..., ..., (HIObjectRef)GetWindowEventTarget(theWindow)); |
or
Listing 2 For a control.
SetFontInfoForSelection(..., ..., ..., (HIObjectRef)GetControlEventTarget(theControl)); |
Even when the header file is fixed in an upcoming release, the typecast, although unnecessary, will still work correctly.
Document Revision History
Date | Notes |
---|---|
2004-10-04 | New document that describes the incorrect prototyping of the SetFontInfoForSelection API and gives a workaround. |
Copyright © 2004 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2004-10-04