API:WindowGetDimensions
From RoR Wiki
UI Lua API · Window functions
Version: WAR 1.4.8
Defined in Lua: interfacecore/source/windowstate.lua
Returns a window's width and height.
width, height = WindowGetDimensions(windowName)
Arguments
- windowName
string– Name of the window.
Returns
- width, height
number– The window's size, before its scale is applied.
Details
- The size is in the window's own units. The size on screen is these values multiplied by the window's scale (WindowGetScale).
- The client registers the C function as
_WindowGetDimensions. TheWindowGetDimensionsthat addons call is a Lua function defined ininterfacecore/source/windowstate.lua:- If the global table named after the window (
_G[windowName]) has aSTATEtable, it returnsSTATE.DIMENSION_XandSTATE.DIMENSION_Ywithout calling into the client. - Otherwise it calls
_WindowGetDimensions(windowName).
- If the global table named after the window (
- For windows with state tracking enabled, the client writes the new size to
windowName.STATE.DIMENSION_XandDIMENSION_Ywhenever the size changes, for example through WindowSetDimensions. - If an addon creates a global table with the same name as a window and gives it a
STATEfield,WindowGetDimensionsreturns whatever that table holds. Avoid usingSTATEas a field name on window tables.
Errors
Error in function call 'WindowGetDimensions': Window %s does not exist(from_WindowGetDimensions)
Example
Making a dialog cover the screen, from easystem_dialogmanager/source/dialogmanager.lua. The root window's size is divided by the interface scale because the dialog's size is scaled when it is drawn:
local x, y = WindowGetDimensions( "Root" ) x = x / InterfaceCore.GetScale() y = y / InterfaceCore.GetScale() WindowSetDimensions( "OneButtonDlg"..dlgIndex, x, y ) -- Set to the screen width and height
