ADC Home > Reference Library > Technical Q&As > Carbon > Human Interface Toolbox >

What is the minimal set of Carbon Events I need to override in order to implement a simple custom push button?


Q: What is the minimal set of Carbon Events I need to override in order to implement a simple custom push button?

A: In order to implement a simple custom push button, you only need to override 3 Carbon Events: kEventControlHitTest, kEventControlHiliteChanged, and kEventControlDraw.

kEventControlHitTest has to be overridden so that you can verify that the point passed as a parameter is indeed in an active part of your control.

Note: contrary to what you might think and what the name suggests (HitTest), this message can be sent even when the button is not down. Do not assume that you just got a click. The Control Manager is just asking you to verify if a point is in a part of your control, nothing more.

kEventControlHiliteChanged, you get this event whenever the HiliteControl API is called on your control. This can happen implicitly during the various mouse tracking APIs: HIViewClick, HandleControlClick, or TrackControl. Most of the time, you should just react by asking for a redraw.

kEventControlDraw, you need to draw your control (or part of it), according to its state, value, etc.

You can see a full implementation of this in the HICustomPushButton sample code


[Nov 12 2002]


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.