View Single Post
11-12-16, 10:55 AM   #1
Infus
A Deviate Faerie Dragon
Join Date: Jul 2016
Posts: 13
Mouse Events and ScrollFrames being broken in 7.1

This code creates a scrollframe and 10 buttons inside that scrollframe. Those buttons are clipped by the scrollframe. And thus only the top 3.5 are visible. In 7.1, the scrollframe no longer clips mouse events, thus clicking on the empty space below the scrollframe registers as clicks on invisible buttons.

Code:
local scrollframe = CreateFrame("ScrollFrame", nil, UIParent)
scrollframe:SetWidth(128);
scrollframe:SetHeight(420);
scrollframe:SetPoint("CENTER");

local content = CreateFrame("Frame", nil, scrollframe)
content:SetPoint("TOPLEFT")
content:SetPoint("TOPRIGHT")
content:SetHeight(1280)
content:SetWidth(128);
scrollframe:SetScrollChild(content)

for i = 0, 10 do
  local button = CreateFrame("BUTTON", nil, content);
  button:SetHeight(128);
  button:SetWidth(128);

  local texture = button:CreateTexture(nil, "OVERLAY");
  texture:SetAllPoints()
  texture:SetTexture("Interface\\PVPFrame\\Icons\\PVP-Banner-Emblem-46");

  button:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -i*128);

  button:SetScript("OnEnter", function() print("hover") end);
  button:SetScript("OnClick", function() print("CLICKED") end);
end