Selection Change Event Handlers

This topic describes how to write custom functions to handle selection change events in an ENVIView.

Arguments

View

A reference to an ENVIView object in which the selection change event occurred.

Graphic

The graphic to be selected or un-selected.

Mode

A value representing the mode used for the current selection. Possible values are:

WasSelected

A value of 1 indicates an item was selected prior to the event; a value of 0 indicates an item was not selected.

Example

The following example opens and displays two different color combinations of the same raster, each in a separate view. Pan in the first view, then pan in the second view. Select the first view again, and the yellow snail trail in the Overview window will redraw and clear the trail where you just panned.

Copy and paste the following code into a new file named ExampleAPIEventsSelection.pro, compile it, then run it.

FUNCTION ExampleAPIEventsSelectionChangeHandler, View, $

  graphic, mode, isSelected

  IF ISA(graphic) && ISA(graphic, 'ENVIRASTERLAYER') && ~isSelected THEN BEGIN

  View.ClearSnailTrail

  ENDIF

  RETURN, 1 ; Perform default event handling

END

 

PRO ExampleAPIEventsSelection

  ; Launch the application

  e = ENVI()

 

  ; Open a raster

  file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $

    SUBDIRECTORY = ['data'])

  raster = e.OpenRaster(file)

 

  ; Create two layers

  view1 = e.GetView()

  v1layer1 = view1.CreateLayer(raster)

  v1layer2 = view1.CreateLayer(raster, /CIR)

  view1.SHOW_OVERVIEW = 1

  view1.SHOW_SNAIL_TRAIL = 1

 

  ; Create two layers in another view in opposite order

  view2 = e.CreateView()

  v2layer1 = view2.CreateLayer(raster, /CIR)

  v2layer2 = view2.CreateLayer(raster)

  view2.SHOW_OVERVIEW = 1

  view2.SHOW_SNAIL_TRAIL = 1

  view1.SetProperty, SELECTION_CHANGE_HANDLER='ExampleAPIEventsSelectionChangeHandler'

  view2.SetProperty, SELECTION_CHANGE_HANDLER='ExampleAPIEventsSelectionChangeHandler'

END