WoW:USERAPI GetQuadrant: Difference between revisions
Jump to navigation
Jump to search
(New page: {{userfunc}} Quick lookup function to find what section of the screen the frame is in. Helpful for anchoring the frame or a tooltip relative to location. Uses the center of the frame, s...) |
m (Move page script moved page USERAPI GetQuadrant to WoW:USERAPI GetQuadrant without leaving a redirect) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
{{userfunc}} | {{userfunc}} | ||
Quick lookup function to find what section of the screen the frame is in. Helpful for anchoring the frame or a tooltip relative to location. Uses the center of the frame, so it will return the quadrant that the majority of the frame lies in if the frame is positioned near the center of the screen. Returns back the quad, horizontal half ("LEFT" or "RIGHT") and the vertical half ("TOP" or "BOTTOM"). | Quick lookup function to find what section of the screen the frame is in. Helpful for anchoring the frame or a tooltip relative to location. Uses the center of the frame, so it will return the quadrant that the majority of the frame lies in if the frame is positioned near the center of the screen. Returns back the quad, horizontal half ("LEFT" or "RIGHT") and the vertical half ("TOP" or "BOTTOM"). | ||
Latest revision as of 04:49, 15 August 2023
This page documents a user-defined function that you can copy and paste into your addon. Replace PREFIX with your addon or lib prefix to avoid conflicts between different versions of these functions.
Quick lookup function to find what section of the screen the frame is in. Helpful for anchoring the frame or a tooltip relative to location. Uses the center of the frame, so it will return the quadrant that the majority of the frame lies in if the frame is positioned near the center of the screen. Returns back the quad, horizontal half ("LEFT" or "RIGHT") and the vertical half ("TOP" or "BOTTOM").
local function GetQuadrant(frame) local x,y = frame:GetCenter() local hhalf = (x > UIParent:GetWidth()/2) and "RIGHT" or "LEFT" local vhalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM" return vhalf..hhalf, vhalf, hhalf end