User-defined events should use atomic event names rather than numbers. See the description of set_event_handler/2.