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: 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

DateNotes
2004-10-04Describes the incorrect prototyping of the SetFontInfoForSelection API and gives a workaround.

Posted: 2004-10-04


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.