'event.id' is the ID of the widget that triggered the event, i.e. the ID of the button if you clicked a button, the ID of the textbox if you typed text into a textbox, etc. 'event.handler' is the ID of the widget, whose event handler is being used. In an IDL Widget program, which implements ***no*** EVENT_PRO or EVENT_FUNC keyword (the usual case for smaller IDL widget programs), the 'event.handler' is usually the ID of the top-level base (i.e. identical to 'event.top'). However, if, for example, a button had set EVENT_PRO or EVENT_FUNC in its WIDGET_BUTTON creation call, then 'event.handler' would be identical to 'event.id' when users clicked on that button. Another common scenario in widget programming is that a group of buttons share one common sub-base, and it is the sub-base who gets the EVENT_PRO or EVENT_FUNC assignment for the whole button group. In this case, if a user clicked one of the buttons in that group, 'event.id' would be the ID of the button, 'event.handler' would be the ID of the WIDGET_BASE sub-base, and 'event.top' is the ID of the top-level base parent (or grandparent) of the sub-base and its buttons.
The general algorithm for event handling, by the way, is that the widget that is the 'event.id' searches up its branches in the widget tree hierarchy for the very first widget on that search path that has an event handler assigned. The first one it finds is the one it uses. If no widget has a specific event handler assigned, then all widgets use the default event handler that is assigned by IDL's XMANAGER call, an event handler which belongs to 'event.top'.
James Jones
James Jones
|