addCBFunction {iSPlot} | R Documentation

## Add a potential callback function for an event

### Description

addCBFunction adds a potential callback function for an event. This callback function will then be available to link to an event through the Event menu on the GUI and through the command line function, setCallFunc.

### Usage

    addCBFunction(callFunction, shortName, preprocessingFun, eventLists)

### Arguments

`callFunction` | the callback function
`shortName` | a short character description of what the callback function does
`preprocessingFun` | a list of functions that must be called before the callback function; these preprocessing functions set values that the callback function will need; if there are no preprocessing functions, then this parameter is set to NULL
`eventLists` | a vector of event names that this callback function can be linked to

### Details

The callback function that is given in the callFunction parameter must take only one argument and that argument must of be of type character to represent a row name from the data frame. This function must create and handle a gUpdateDataMessage so that the data is updated.

Not all callback functions will need preprocessing functions so this parameter can be set to NULL. If the callback function needs some information besides the row name (which is the only parameter a callback function has), then the callback function must have one or more preprocessing functions. For example, when the callback function is to color a point, there must be a preprocessing function that has the user set the color they want to use.

Currently, the eventLists parameter can be a vector containing one or more of the following events: "mouseOver", "leftButtonClick", "middleButtonClick", "rightButtonClick".

### Author(s)

Elizabeth Whalen

### See Also

`getEvents`, `getDescForEvent`, `setCallFunc`

### Examples

      if (interactive())
      {
        loadData("USArrests")
        setActiveMVC("USArrests")
        getDescForEvent("leftButtonClick")

        changePch<-function(rowName)
        {
          curMVC<-getMVCFromWinNum()
          virtualData<-virtualData(model(curMVC))

          # column name
          colName<-"pch"

          # need to change the virtualData slot in model object
          # using messages
          # for this example, just set the pch value to 2
          colIndex<-match(colName, colnames(virtualData))
          rowIndex<-match(rowName, rownames(virtualData))
          # determining the pch value should be set in a preprocessing function
          newPchValue<-2

          mData<-as.list(newPchValue)
          names(mData)<-rowName

          # if a point was clicked, then we want to create a
          # gUpdateDataMessage
          dfMessage<-new("gUpdateDataMessage", type=colName, mData=mData,
                     dataName=modelName(model(curMVC)), from="")
          handleMessage(dfMessage)
        }

        addCBFunction(changePch, "change the plotting character", NULL,
        c("leftButtonClick", "middleButtonClick", "rightButtonClick"))

        getDescForEvent("leftButtonClick")
      }

[Package iSPlot version 1.12.0 Index]