3105
Workaround for capturing mouse click events in an ENVI display window
Topic:
This article describes one method for capturing a mouse click event within an ENVI display window. This method is most useful if the mouse click event is supposed to relate to a change in focus within the display window (user clicks on a new location within the window). You are not capturing the mouse click directly, but instead capturing a change in cursor location within the window.
Discussion:
It is possible to capture ENVI mouse click events within a display window using documented routines -- however it is not straightforward. Here are the necessary steps:
- Create a top level base widget that will not be visible to the user while your program is running.
- Call WIDGET_CONTROL in the following manner: WIDGET_CONTROL, Widget_Id, TIMER=interval_in_seconds. Set the timer value to a small value (one second or less, perhaps). Every time that increment of time passes, the timer widget will fire off an event, which can be captured by another program which responds to the arrival of the event as if a mouse click was generated.
Note:
A timer widget event is identical to any other widget event except that it contains only the 3 standard event tags. These event structures are defined as:
{ WIDGET_TIMER, ID:0L, TOP:0L, HANDLER:0L }
It is left to the caller to tell the difference between standard widget events and timer events. The standard way to do this is to use a widget that doesn't normally generate events (e.g., a base or label). Alternately, the TAG_NAMES function can be called with the STRUCTURE_NAME keyword to differentiate a WIDGET_TIMER event from other types of events. For example:
IF TAG_NAMES(event, /STRUCTURE_NAME) EQ $
'WIDGET_TIMER' THEN ...
Using the TIMER keyword is more efficient than the background task functionality found in the XMANAGER procedure because it doesn't "poll" like the original background task code.