Important: The information in this document is obsolete and should not be used for new development.
MyPanelEvent
A control panel extension must respond to thekPanelEventSelect
request 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 thekPanelEventSelect
request 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;
globals
- A handle to the control panel extension's global data.
dialog
- 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.
itemOffset
- An offset to the panel's first item.
theEvent
- An event record describing the event being reported to your control panel extension.
itemHit
- 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
MyPanelEvent
function has handled the event, it should return the item number of the associated item in this parameter.handled
- On entry, the value
FALSE
for mouse events; the valueTRUE
for all other events. On exit, theMyPanelEvent
function should return a Boolean value that indicates whether it has handled the event (TRUE
) or has not handled the event (FALSE
).DESCRIPTION
YourMyPanelEvent
function is called whenever an event occurs in your panel. The parametertheEvent
contains 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.The
MyPanelEvent
function is intended to operate just like an event filter function specified in calls to theModalDialog
procedure or other Dialog Manager routines. The main difference betweenMyPanelEvent
and other event filter functions is thatMyPanelEvent
does not return a Boolean value as its function result. Instead, it indicates whether it handled the event in thehandled
parameter.If the specified event is a mouse event, you might prefer your extension's
MyPanelItem
function to handle the event. In that case, you should returnFALSE
in thehandled
parameter. Otherwise, you should attempt to handle the event.If your
MyPanelEvent
function does handle the event, it should update theitemHit
parameter to reflect the affected item and returnTRUE
in thehandled
parameter. If you sethandled
toFALSE
, the owning control panel sends your panel an item-select request.RESULT CODES
YourMyPanelEvent
function should returnnoErr
if successful, or an appropriate result code otherwise.SEE ALSO
For an exampleMyPanelEvent
function, see Listing 5-6 on page 5-18. See the description ofMyPanelItem
on 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.