add.event.handler

Description

Add a Handler to an Event

Usage

1
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.

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.

Value

Nothing good.

Author(s)

Brad Friedman

Examples

1
2
3
4
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)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.