Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:WindowAddAnchor

From RoR Wiki

UI Lua API · Window functions
Version: WAR 1.4.8

Adds an anchor that attaches a point of a window to a point of another window.

WindowAddAnchor(windowName, point, relativeTo, relativePoint, xOffset, yOffset)

Arguments

windowName
string – Name of the window to anchor.
point
string – Point on the relativeTo window.
relativeTo
string – Name of the window to anchor to. "Root" is the whole screen.
relativePoint
string – Point on the anchored window (windowName) that is placed on point.
xOffset, yOffset
number – Offset from point. A positive yOffset moves the window down.

Returns

Nothing.

Details

  • Valid point names are "topleft", "top", "topright", "left", "center", "right", "bottomleft", "bottom" and "bottomright". Case does not matter.
  • An unknown point name is not rejected. The anchor is stored with the point "none", which is what WindowGetAnchor then reports.
  • The second argument names the point on the other window and the fourth names the point on the window being anchored. For example, WindowAddAnchor(new, "bottom", previous, "top", 0, 0) puts the top of new on the bottom of previous, so new sits below it.
  • The anchor is added to the window's existing anchors. Nothing is replaced, so call WindowClearAnchors first if the window should only follow the new anchor.
  • relativeTo must name an existing window when the call is made. The client stores the name, not the window.
  • The window and its child windows are laid out again straight away.
  • How anchors are applied:
    • With one anchor, the anchor sets the window's position.
    • With two anchors, the anchors set the position and, if both relative points are corners, the size too. Two opposite corners (for example "topleft" and "bottomright") set width and height. Two corners on the same edge set only the width or only the height.
    • With three or more anchors, the client does not position the window from its anchors at all.
    • If an anchor's relative window cannot be found when the anchors are processed, the window is not repositioned.
  • All four names must be strings and both offsets must be numbers.

Errors

  • Error in function call 'WindowAddAnchor': Window %s does not exist
  • Error in function call 'WindowAddAnchor': Relative window %s does not exist
  • Error in function call 'WindowAddAnchor': Window %s is currently locked and may not be modified from lua. ...
    This check never triggers in the current client. See WindowSetShowing.

Example

Stacking colour boxes in a column, from ea_guildwindow/source/colorpicker.lua:

WindowAddAnchor( newWindowName, "bottom", previousWindowName, "top", 0, 0 )

Making a window fill its parent with two corner anchors, from easystem_glyphdisplay/source/glyphdisplay.lua:

WindowClearAnchors (self.windowName);
WindowAddAnchor (self.windowName, "topleft", self.parentName, "topleft", 0, 0);
WindowAddAnchor (self.windowName, "bottomright", self.parentName, "bottomright", 0, 0);

See also