connectEventHandlers {RDCOMEvents}R Documentation

Simple facility for registering functions as event handlers for a connection point.

Description

This function is just a simplified version of a sequence of steps used to create a COM event server from a collection of methods and an interface definition and then connect this server to an event source/connection point. This function makes it a single action. It leverages the IExpandedConnectionPoint-class class to provide a self-describing connection point.

Usage

connectEventHandlers(eventSource, methods, 
                     lib = LoadTypeLib(eventSource@source),
                     iface = lib[[eventSource@guid]])

Arguments

eventSource the connection point. This is expected to be of class IExpandedConnectionPoint
methods a named list of functions. These are the functions that implement the methods of the event handler interface expected for this connection point. These are passed to createCOMEventServerInfo.
lib the type library that contains the definition of the interface for this connection point's events. This is computed from the source field of the eventSource argument. It is a parameter to this function to allow those who have already loaded the library to pass it directly.
iface this ITypeInfo object that provides the definition of the interface for an event sink/handler for this connection point. If this is specified, the lib is not used. Therefore, if this has been pre-computed, it can be provided as an argument to this function call. Otherwise, it is computed using the UUID in the IExpandedConnectionPoint-class object given in eventSource.

Details

Value

A list with 2 elements:

server the COM server instance that was registered with the event source.
cookie the identifier or cookie returned from connectConnectionPoint that can be used to unregister/disconnect the event handler.

Author(s)

Duncan Temple Lang <duncan@wald.ucdavis.edu>

References

http://www.omegahat.org/RDCOMClient http://www.omegahat.org/RDCOMServer http://www.omegahat.org/SWinTypeLibs http://www.omegahat.org/SWinRegistry

See Also

findConnectionPoint getConnectionPoints

createCOMEventServerInfo createCOMEventServer

connectConnectionPoint Unadvise

Examples


## Not run: 
  library(RDCOMClient)
  library(SWinTypeLibs)  
  e = getCOMInstance("Excel.Application")
  point = getConnectionPoints(e)[[1]]

  v = connectEventHandlers(point,
                            list(SheetChange = function(Sh, Target) {
                                                  cat("Sheet has been changed\n")
                                               }))
## End(Not run)

[Package RDCOMEvents version 0.3-1 Index]