![]() |
ControlKeyFilterProcPtr |
||||
Header: | Controls.h | Carbon status: | Supported | |
The key filter function allows for the interception and possible changing of keystrokes destined for a control.
typedef ControlKeyFilterResult(* ControlKeyFilterProcPtr) ( ControlRef theControl, SInt16 *keyCode, SInt16 *charCode, EventModifiers *modifiers );
You would declare your function like this if you were to name it MyControlKeyFilterCallback:
ControlKeyFilterResult MyControlKeyFilterCallback ( ControlRef theControl, SInt16 *keyCode, SInt16 *charCode, EventModifiers *modifiers );
A handle to the control in which the mouse-down event occurred.
The virtual key code derived from the event structure. This value represents the key pressed or released by the user. It is always the same for a specific physical key on a particular keyboard regardless of which modifier keys were also pressed.
A particular character derived from the event structure. This value depends on the virtual key code, the state of the modifier keys, and the current 'KCHR' resource.
The constant in the modifiers field of the event structure specifying the state of the modifier keys and the mouse button at the time the event was posted.
Returns a value indicating whether or not it allowed or blocked keystrokes; see
Controls that support text input (such as editable text and list box controls) can attach a key filter function to filter key strokes and modify them on return.
The Control Manager defines the data type ControlKeyFilterUPP to identify the universal procedure pointer for this application-defined function:
typedef UniversalProcPtr ControlKeyFilterUPP;
You typically use the NewControlKeyFilterProc macro like this:
ControlKeyFilterUPP myControlKeyFilterUPP;
myControlKeyFilterUPP = NewControlKeyFilterProc(MyControlKeyFilterCallback);
You typically use the CallControlKeyFilterProc macro like this:
CallControlKeyFilterProc(myControlKeyFilterUPP, theControl, keyCode, charCode, modifiers);
Your key filter function can intercept and change keystrokes destined for a control. Your key filter function can change the keystroke, leave it alone, or block your control definition function from receiving it. For example, an editable text control can use a key filter function to allow only numeric values to be input in its field.
This function is available with Appearance Manager 1.0 and later.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)