MyPanelEventA control panel extension must respond to the
kPanelEventSelectrequest code. A control panel sends this request code to your extension whenever an event occurs in your panel. A control panel extension typically responds to the
kPanelEventSelectrequest code by calling an extension-defined subroutine (for example,
MyPanelEvent) to handle the request.
FUNCTION MyPanelEvent (globals: Handle; dialog: DialogPtr; itemOffset: Integer; theEvent: eventRecord; VAR itemHit: Integer; VAR handled: Boolean): ComponentResult;
- A handle to the control panel extension's global data.
- A pointer to the dialog record of the owning control panel. The owning control panel displays your items in the dialog box (of the control panel) referenced through this parameter.
- An offset to the panel's first item.
- An event record describing the event being reported to your control panel extension.
- On entry, the item number of an item. This number is valid only for mouse events (on input, do not interpret this parameter for any other type of event). On exit, if the
MyPanelEventfunction has handled the event, it should return the item number of the associated item in this parameter.
- On entry, the value
FALSEfor mouse events; the value
TRUEfor all other events. On exit, the
MyPanelEventfunction should return a Boolean value that indicates whether it has handled the event (
TRUE) or has not handled the event (
MyPanelEventfunction is called whenever an event occurs in your panel. The parameter
theEventcontains a complete description of the event. A control panel handles events in its own items and also gives your component a chance to handle events in its own panel.
MyPanelEventfunction is intended to operate just like an event filter function specified in calls to the
ModalDialogprocedure or other Dialog Manager routines. The main difference between
MyPanelEventand other event filter functions is that
MyPanelEventdoes not return a Boolean value as its function result. Instead, it indicates whether it handled the event in the
If the specified event is a mouse event, you might prefer your extension's
MyPanelItemfunction to handle the event. In that case, you should return
handledparameter. Otherwise, you should attempt to handle the event.
MyPanelEventfunction does handle the event, it should update the
itemHitparameter to reflect the affected item and return
handledparameter. If you set
FALSE, the owning control panel sends your panel an item-select request.
MyPanelEventfunction should return
noErrif successful, or an appropriate result code otherwise.
SEE ALSOFor an example
MyPanelEventfunction, see Listing 5-6 on page 5-18. See the description of
MyPanelItemon page 5-25 for information on handling clicks in dialog items. For a description of the fields of the event record, see the chapter "Event Manager" in Inside Macintosh: Macintosh Toolbox Essentials.