Bug 629

Summary: [Chameleon - Widget] Add ability for ROI to call JS function when changed
Product: Chameleon Reporter: Paul Spencer <pspencer@dmsolutions.ca>
Component: WidgetAssignee: chameleon-dev <chameleon-dev@lists.maptools.org>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P1    
Version: 1.99   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description From 2004-08-25 14:46:04
Need the ability to call an arbitrary javascript function when the ROI changes.
------- Comment #1 From 2004-08-25 14:55:32 -------
This should be an optional attribute.  The function should be albe to accept 
arguments as discussed.
------- Comment #2 From 2004-08-25 15:12:29 -------
ability added.  ROIManager now has a ONROICHANGED attribute that can be set to
some javascript code to be executed when the ROI changes in some way.  

The implementation adds three new methods to the global ROI Manager object:

Public Functions:

* RegisterEvent( event, code )

this is called by a client of the ROIManager that wants to be informed when an
event happens.  In the case of the ROIManager widget, it automatically registers
the code in the ONROICHANGED attribute ... but any javascript code can
theoretically use it.

* DeregisterEvent( event, code )

this is called by a client to remove a registered call back.  Pass the same code
as was passed to the RegisterEvent

Private Functions:

TriggerEvent( event )

this is called internally to signal that an event has occurred, this function
will then invoke all the callbacks registered for an event.

There is currently only one event registered:

ROI_CHANGED

it is declared as a global javascript variable, so your code would look like:

<script>
function myROICallback()
{
    alert( 'roi changed' );
}
goROIManager.RegisterEvent( ROI_CHANGED, 'myROICallback( )' );
</script>