Get the module link instance pointer for a widget
#include <Ap.h> PtWidget_t *ApGetInstance( PtWidget_t *widget );
ApGetInstance() is used to obtain the widget's module link instance pointer. For most modules, PhAB generates manifests that let you access the widgets within that module directly, provided only one instance of the module exists at a time.
Because window modules allow you to have multiple instances, you can't always use the direct access manifests; the manifest will only be valid for the last instance of the window. For windows, you may need either to save the module link_instance pointer when creating the window, or to use this function within the callback to determine the origin of the callback.
The module link instance pointer for the widget, or NULL if it cannot be determined.
PtArg_t args[1]; mywindow_callback( PtWidget_t *widget, ... ) { PtWidget_t *window; /* from which window did this come? */ if ( window = ApGetInstance( widget ) ) { /* set the widget selected to red */ PtSetArg( &args[0], Pt_ARG_FILL_COLOR, Pg_RED, 0 ); PtSetResources( ApGetWidgetPtr( window, ApName( widget ) ), 1, args ); } return( Pt_CONTINUE ); }
An interesting observation about this callback example is that it doesn't know which window is being modified or which widget gets changed. It acts on whatever widget the user selects. |
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |