Learn R Programming

AnalysisPageServer (version 1.6.2)

add.event.handler: add.event.handler

Description

Add a Handler to an Event

Usage

add.event.handler(registry, event, handler)

Arguments

registry
EventRegistry
event
String. Name of the Event
handler
Function. The new Handler to add to the Event.

Value

Nothing good.

Details

A Handler is any function to be called when the event is triggered. If the return value of the Handler has a "CatchEvent" attribute which is TRUE then the event will be caught and not bubble to the next handler, and the "CatchEvent" attribute will be stripped before returning the value to the triggering context.

If the Event does not yet exist an error is thrown.

Examples

Run this code
r <- new.event.registry()
add.event(r, "mouseclick")
add.event.handler(r, "mouseclick", function(x, y)  message("Mouse clicked at coordinates (", x, ", ", y, ")"))
trigger.event(r, "mouseclick", x = 30, y = 50)

Run the code above in your browser using DataLab