<?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%3AWindowAddAnchor</id>
	<title>API:WindowAddAnchor - 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%3AWindowAddAnchor"/>
	<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:WindowAddAnchor&amp;action=history"/>
	<updated>2026-10-17T16:47:42Z</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:WindowAddAnchor&amp;diff=30861&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:WindowAddAnchor&amp;diff=30861&amp;oldid=prev"/>
		<updated>2026-10-16T19:51:18Z</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=Window}}&lt;br /&gt;
Adds an anchor that attaches a point of a window to a point of another window.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WindowAddAnchor(windowName, point, relativeTo, relativePoint, xOffset, yOffset)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Arguments ==&lt;br /&gt;
;windowName : &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; – Name of the window to anchor.&lt;br /&gt;
;point : &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; – Point on the &amp;lt;code&amp;gt;relativeTo&amp;lt;/code&amp;gt; window.&lt;br /&gt;
;relativeTo : &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; – Name of the window to anchor to. &amp;lt;code&amp;gt;&amp;quot;Root&amp;quot;&amp;lt;/code&amp;gt; is the whole screen.&lt;br /&gt;
;relativePoint : &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; – Point on the anchored window (&amp;lt;code&amp;gt;windowName&amp;lt;/code&amp;gt;) that is placed on &amp;lt;code&amp;gt;point&amp;lt;/code&amp;gt;.&lt;br /&gt;
;xOffset, yOffset : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Offset from &amp;lt;code&amp;gt;point&amp;lt;/code&amp;gt;. A positive &amp;lt;code&amp;gt;yOffset&amp;lt;/code&amp;gt; moves the window down.&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Nothing.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
* Valid point names are &amp;lt;code&amp;gt;&amp;quot;topleft&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;top&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;topright&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;left&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;center&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;right&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;bottomleft&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;bottom&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;quot;bottomright&amp;quot;&amp;lt;/code&amp;gt;. Case does not matter.&lt;br /&gt;
* An unknown point name is not rejected. The anchor is stored with the point &amp;lt;code&amp;gt;&amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;, which is what [[API:WindowGetAnchor|WindowGetAnchor]] then reports.&lt;br /&gt;
* The second argument names the point on the &amp;#039;&amp;#039;&amp;#039;other&amp;#039;&amp;#039;&amp;#039; window and the fourth names the point on the window being anchored. For example, &amp;lt;code&amp;gt;WindowAddAnchor(new, &amp;quot;bottom&amp;quot;, previous, &amp;quot;top&amp;quot;, 0, 0)&amp;lt;/code&amp;gt; puts the top of &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; on the bottom of &amp;lt;code&amp;gt;previous&amp;lt;/code&amp;gt;, so &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; sits below it.&lt;br /&gt;
* The anchor is added to the window&amp;#039;s existing anchors. Nothing is replaced, so call [[API:WindowClearAnchors|WindowClearAnchors]] first if the window should only follow the new anchor.&lt;br /&gt;
* &amp;lt;code&amp;gt;relativeTo&amp;lt;/code&amp;gt; must name an existing window when the call is made. The client stores the name, not the window.&lt;br /&gt;
* The window and its child windows are laid out again straight away.&lt;br /&gt;
* How anchors are applied:&lt;br /&gt;
** With one anchor, the anchor sets the window&amp;#039;s position.&lt;br /&gt;
** With two anchors, the anchors set the position and, if both relative points are corners, the size too. Two opposite corners (for example &amp;lt;code&amp;gt;&amp;quot;topleft&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;quot;bottomright&amp;quot;&amp;lt;/code&amp;gt;) set width and height. Two corners on the same edge set only the width or only the height.&lt;br /&gt;
** With three or more anchors, the client does not position the window from its anchors at all.&lt;br /&gt;
** If an anchor&amp;#039;s relative window cannot be found when the anchors are processed, the window is not repositioned.&lt;br /&gt;
* All four names must be strings and both offsets must be numbers.&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;WindowAddAnchor&amp;#039;: Window %s does not exist&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;WindowAddAnchor&amp;#039;: Relative window %s does not exist&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;WindowAddAnchor&amp;#039;: Window %s is currently locked and may not be modified from lua. ...&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;This check never triggers in the current client. See [[API:WindowSetShowing|WindowSetShowing]].&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Stacking colour boxes in a column, from &amp;lt;code&amp;gt;ea_guildwindow/source/colorpicker.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WindowAddAnchor( newWindowName, &amp;quot;bottom&amp;quot;, previousWindowName, &amp;quot;top&amp;quot;, 0, 0 )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Making a window fill its parent with two corner anchors, from &amp;lt;code&amp;gt;easystem_glyphdisplay/source/glyphdisplay.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WindowClearAnchors (self.windowName);&lt;br /&gt;
WindowAddAnchor (self.windowName, &amp;quot;topleft&amp;quot;, self.parentName, &amp;quot;topleft&amp;quot;, 0, 0);&lt;br /&gt;
WindowAddAnchor (self.windowName, &amp;quot;bottomright&amp;quot;, self.parentName, &amp;quot;bottomright&amp;quot;, 0, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[API:WindowClearAnchors|WindowClearAnchors]]&lt;br /&gt;
* [[API:WindowGetAnchor|WindowGetAnchor]]&lt;br /&gt;
* [[API:WindowGetAnchorCount|WindowGetAnchorCount]]&lt;br /&gt;
* [[API:WindowForceProcessAnchors|WindowForceProcessAnchors]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>