# InstallPanelCallback

int InstallPanelCallback (int panelHandle, PanelCallbackPtr eventFunction, void *callbackData);

## Purpose

Installs a panel callback.

InstallPanelCallback takes a panel handle, the name of the event function, type PanelCallbackPtr, that processes events for that panel, and callback data of any type.

After you install the callback, the event function is called whenever the user generates an event on the panel.

The event function receives the panel handle of the panel generating the event; the type of the event, such as a left mouse click, and any additional event data, such as the mouse position at the time of a left mouse click; and the callback data for processing.

You do not need to call InstallPanelCallback if you already associated a callback function with the panel in the User Interface Editor.

Callbacks are initiated through RunUserInterface or GetUserEvent.

| Note To uninstall the callback, pass NULL for eventFunction.

## Parameters

Input
Name | Type | Description
panelHandle | integer | Specifier for a particular panel that is currently in memory. You obtain this handle from LoadPanel, NewPanel, or DuplicatePanel.
eventFunction | PanelCallbackPtr | Name of the function that processes the panel events. The event function, type PanelCallbackPtr, takes the following form: int CVICALLBACK EventFunctionName (int panelHandle, int event, void *callbackData, int eventData1, int eventData2); The event function receives the panel handle of the panel generating the event; the type of the event, such as a left mouse click, and any additional event data, such as the mouse position at the time of a left mouse click; and the callback data for processing. The following is a list of events and associated event data:
Event | Event Data
EVENT_LEFT_CLICK | eventData1 = mouse vert position eventData2 = mouse horiz position
EVENT_LEFT_DOUBLE_CLICK | eventData1 = mouse vert position eventData2 = mouse horiz position
EVENT_RIGHT_CLICK | eventData1 = mouse vert position eventData2 = mouse horiz position
EVENT_RIGHT_DOUBLE_CLICK | eventData1 = mouse vert position eventData2 = mouse horiz position
EVENT_KEYPRESS | eventData1 = keypressed eventData2 = ptr to keypressed
EVENT_GOT_FOCUS | eventData1 and eventData2 are not used
EVENT_LOST_FOCUS | eventData1 and eventData2 are not used
EVENT_CLOSE | eventData1 and eventData2 are not used
EVENT_PANEL_SIZE | eventData1 and eventData2 are not used
EVENT_PANEL_MOVE | eventData1 and eventData2 are not used
EVENT_DISCARD | eventData1 and eventData2 not used
User callbacks must always return 0 unless they intend to swallow the event to which they are responding. To swallow the event, the callback should return 1.
| Note To uninstall the callback, pass NULL for this parameter.
callbackData | void * | Points to data that you define. The callback function receives the pointer.

## Return Value

Name | Type | Description
status | integer | Return value indicating whether the function was successful. A negative number indicates that an error occurred.
Code | Error Message String
xx | Success