<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3ARegisterEventHandler</id>
	<title>API:RegisterEventHandler - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3ARegisterEventHandler"/>
	<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:RegisterEventHandler&amp;action=history"/>
	<updated>2026-11-12T03:43:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.returnofreckoning.com/index.php?title=API:RegisterEventHandler&amp;diff=30656&amp;oldid=prev</id>
		<title>Maintenance script: UI Lua API import (WAR 1.4.8)</title>
		<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:RegisterEventHandler&amp;diff=30656&amp;oldid=prev"/>
		<updated>2026-10-16T19:48:00Z</updated>

		<summary type="html">&lt;p&gt;UI Lua API import (WAR 1.4.8)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{LuaApi|group=Interface}}&lt;br /&gt;
Registers a Lua function to be called whenever a UI event is raised.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RegisterEventHandler(eventId, functionName)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Arguments ==&lt;br /&gt;
;eventId : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Id of the event, usually a value from &amp;lt;code&amp;gt;SystemData.Events&amp;lt;/code&amp;gt;.&lt;br /&gt;
;functionName : &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; – Name of the Lua function to call, as a dotted path from the global table, for example &amp;lt;code&amp;gt;&amp;quot;MyAddon.OnLoadingEnd&amp;quot;&amp;lt;/code&amp;gt;. It is a name, not a function value.&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Nothing.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
* Each time the event is raised, the client looks up &amp;lt;code&amp;gt;functionName&amp;lt;/code&amp;gt; and calls it. The handler receives the arguments carried by the event. Events raised with [[API:BroadcastEvent|BroadcastEvent]] carry none.&lt;br /&gt;
* One event can have any number of handlers, and one function can handle several events. Registering the same function for the same event a second time is refused with an error.&lt;br /&gt;
* The client remembers which UI module was being loaded or initialized when the handler was registered, and makes that module current while the handler runs.&lt;br /&gt;
* Handlers can register or unregister handlers while an event is being delivered. Each handler is called at most once per delivery.&lt;br /&gt;
* Handlers stay registered until [[API:UnregisterEventHandler|UnregisterEventHandler]] is called with the same event id and the same name.&lt;br /&gt;
* Handlers that belong to a window are registered with [[API:WindowRegisterEventHandler|WindowRegisterEventHandler]] instead; they are stored on the window, not in this list.&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
These are written to the UI log; the call returns normally.&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;RegisterEventHandler&amp;#039;: Invalid Event Id&amp;lt;/code&amp;gt; (event id 0)&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;RegisterEventHandler&amp;#039;: Invalid Script Name&amp;lt;/code&amp;gt; (empty name)&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;RegisterEventHandler&amp;#039;: Script %s is already registered for event #%d&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
From &amp;lt;code&amp;gt;easystem_actionbarclustermanager/source/actionbarclustermanager.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RegisterEventHandler (SystemData.Events.PLAYER_CAREER_LINE_UPDATED, &amp;quot;ActionBarClusterManager.SpawnCluster&amp;quot;)&lt;br /&gt;
RegisterEventHandler (SystemData.Events.LOADING_END,                &amp;quot;ActionBarClusterManager.SpawnCluster&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From &amp;lt;code&amp;gt;interfacecore/interfacecore.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RegisterEventHandler( SystemData.Events.RESOLUTION_CHANGED, &amp;quot;InterfaceCore.OnResolutionChanged&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[API:UnregisterEventHandler|UnregisterEventHandler]]&lt;br /&gt;
* [[API:BroadcastEvent|BroadcastEvent]]&lt;br /&gt;
* [[API:WindowRegisterEventHandler|WindowRegisterEventHandler]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>