API:WindowGetAnchor
From RoR Wiki
UI Lua API · Window functions
Version: WAR 1.4.8
Returns one of a window's anchors.
point, relativePoint, relativeTo, xOffset, yOffset = WindowGetAnchor(windowName, anchorIndex)
Arguments
- windowName
string– Name of the window.- anchorIndex
number– Which anchor to read, starting at 1.
Returns
- point
string– Point on the relative window, for example"bottomleft".- relativePoint
string– Point on this window.- relativeTo
string– Name of the window the anchor is attached to.- xOffset, yOffset
number– The anchor's offsets.
Details
- The order differs from WindowAddAnchor, which takes
relativeTobeforerelativePoint. Copy an anchor withWindowAddAnchor(name, point, relativeTo, relativePoint, xOffset, yOffset). - Anchors are counted in the order they were added. WindowGetAnchorCount gives the number of anchors.
anchorIndexis truncated to a whole number.- A point name the client did not recognise when the anchor was added is returned as
"none". - If the anchor has no relative window name, the name of the window's parent is returned instead. For a window without a parent, an empty wide string (
L"") is returned in that case. - The function needs at least two arguments and only reads the last two.
Errors
Error in function call 'WindowGetAnchor'
Raised both when the window does not exist and whenanchorIndexis less than 1 or greater than the number of anchors. The message does not say which.
Example
Copying all anchors from one window to another with an extra offset, from easystem_layouteditor/source/layouteditorutils.lua:
WindowClearAnchors( destinationWindow )
local numAnchors = WindowGetAnchorCount( sourceWindow )
for index = 1, numAnchors
do
local point, relativePoint, relativeTo, xoffs, yoffs = WindowGetAnchor( sourceWindow, index )
WindowAddAnchor( destinationWindow , point, relativeTo, relativePoint, xoffs+xOffset, yoffs+yOffset )
end
