WwHandler Function
Adds or removes a PV‑WAVE Widgets event handler from a widget.
Usage
status = WwHandler(wid, handler[, mask[, userdata]])
Input Parameters
wid — The widget ID that the event handler is to be removed from or added to.
handler — The name of the event handler procedure.
mask — (optional) The mask for the event. This parameter must be specified if the Add keyword is used.
userdata — (optional) Stores the value of the specified variable.
Returned Value
status — A value indicating success or failure of the addition or removal of the event handler.
*1 — Indicates success.
*0 — Indicates failure.
Keywords
Add — Add an event handler for the event specified by the mask parameter. The mask input parameter must be specified when the Add keyword is used.
Remove — Remove the specified event handler.
Event Handler Parameters
The following parameters are required for the event handler procedure:
wid — The ID of the widget from which the event handler is called.
userdata — Stores the value of the specified variable.
event — An opaque event handle to be used in subsequent calls to request event data.
Discussion
The mask parameter can be specified as a value (such as, ButtonPressMask), if you include the Standard Library file wtxlib.pro using the @ (at) command: @wtxlib.
One way to improve the portability of your application is to specify mask by name, instead of value. An example of specifying by name is: 'ButtonPressMask'.
Example
This example creates a simple PV‑WAVE widget event handler. The mask parameter for this handler is the 'PointerMotionMask'. A list of event definitions can be found in wtxlib.pro found in the Standard Library.
The event handler procedure, GetHandler, is registered with the drawing area widget. The GetHandler procedure is called when the mouse is motioned over the drawing area. The GetHandler prints the position of the mouse as it is dragged over the drawing area.
Enter the callback procedures and main procedure into a file, and compile the procedure with the .RUN command. To run the example, enter wwhandler_ex at the WAVE> prompt. To dismiss the widgets, select the appropriate function (such as Close) from the window manager menu of the Command button (the parent widget).
PRO GetHandler, wid, userdata, event
   COMMON d, c, key
   PRINT, WwGetPosition(event)
END
 
PRO DrawCB, wid, index
   COMMON d, c, key
   IF c EQ 0 THEN TVSCL, DIST(500)
   c = 1
END
 
PRO wwhandler_ex
   COMMON d, c, key
   c = 0
   key = ''
   top = WwInit('ww_ex101', 'wwhandler_ex', layout)
   wid = WwDrawing(layout, windowid, 'DrawCB', [600,600], $
      [500,500], Area=area)
   status = WwHandler(area, 'GetHandler', 'PointerMotionMask', $
      /Add)
   status = WwSetValue(top, /Display)
   WwLoop
END
For a further example of WwHandler, see the example for the WwGetPosition Function.
See Also