|
User Interface Programming: Using Draw Widgets |
|
To go beyond merely displaying an image in a draw widget and allow the user to interact in some way with the displayed image, you must configure the draw widget to generate either button, motion, wheel, or keyboard events:
| Note Wheel events are enabled only under Microsoft Windows. |
The following example uses motion events to update the values of several label widgets as the mouse cursor moves over an image in a draw widget. This and several other features are discussed in the section following the code.
| Example Code See the file draw_widget_data.pro in the examples/doc/widgets subdirectory of the IDL distribution for the example code. You can either open the file in an IDL editor window and compile and run the code using items on the Run menu, or simply enter draw_widget_dataat the IDL command prompt. See Running the Example Code if IDL does not run the program as expected. You may need to enter DEVICE, DECOMPOSED=1 at the IDL command prompt before running this example. |
The following things about this example are worth noting:
stash structure, but since the image could be large, we choose to pass a pointer to the image instead. This means we must dereference the pointer variable every time we need to use the image data. For more information on pointers and how to dereference them, see Pointers.
IDL Online Help (March 06, 2007)