Quantcast

Make sure the dropdown stays on the screen

Adrian L Lange [09-15-14 - 01:27]
Make sure the dropdown stays on the screen
Filename
Broker_Equipment.lua
diff --git a/Broker_Equipment.lua b/Broker_Equipment.lua
index 987d322..12e5803 100644
--- a/Broker_Equipment.lua
+++ b/Broker_Equipment.lua
@@ -174,7 +174,22 @@ function LDB:OnClick(button)
 		else
 			UpdateMenu(self)
 			Menu:ClearAllPoints()
-			Menu:SetPoint('TOP', self, 'BOTTOM')
+			Menu:SetPoint('TOP', self, 'BOTTOM') -- temporary anchor
+
+			local sideAnchor = ''
+			if(Menu:GetRight() > GetScreenWidth()) then
+				sideAnchor = 'RIGHT'
+			elseif(Menu:GetLeft() <= 0) then
+				sideAnchor = 'LEFT'
+			end
+
+			Menu:ClearAllPoints()
+			if(Menu:GetBottom() <= 0) then
+				Menu:SetPoint('BOTTOM' .. sideAnchor, self, 'TOP' .. sideAnchor)
+			else
+				Menu:SetPoint('TOP' .. sideAnchor, self, 'BOTTOM' .. sideAnchor)
+			end
+
 			Menu:Show()
 		end