Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:WindowGetScreenPosition

From RoR Wiki

UI Lua API · Window functions
Version: WAR 1.4.8

Returns the screen position of a window's top-left corner.

x, y = WindowGetScreenPosition(windowName)

Arguments

windowName
string – Name of the window.

Returns

x, y
number – Position of the top-left corner in screen pixels, measured from the top-left of the screen.

Details

  • The values are in screen pixels. Unlike WindowGetOffsetFromParent, they are not divided by the window's scale.
  • To get the size on screen to go with the position, multiply WindowGetDimensions by the window's scale.
  • Positions set by anchors are only up to date after the anchors have been processed. WindowForceProcessAnchors processes them immediately.

Errors

  • Error in function call 'WindowGetScreenPosition': Window %s does not exist

Example

Keeping a frame on screen, from easystem_layouteditor/source/layoutcontrolframe.lua:

local screenWidth, screenHeight = GetScreenResolution()
local screenX, screenY          = WindowGetScreenPosition( self:GetName() )
local width, height             = WindowGetDimensions( self:GetName() )

width   = width*uiScale
height  = height*uiScale

See also