两种方法加入框体移动
xml中代码:
<Frame name="MyFrame" frameStrata="DIALOG" toplevel="true" enableMouse="true" movable="true" hidden="true" parent="UIParent" enableKeyboard="true" > <Size> <AbsDimension x="500" y="380"/> </Size> <Scripts> <OnLoad>this:RegisterForDrag("LeftButton");</OnLoad> <OnDragStart>this:StartMoving();</OnDragStart> <OnDragStop>this:StopMovingOrSizing();</OnDragStop> <OnMouseDown> this:SetClampedToScreen(true) </OnMouseDown> </Scripts> …… </Frame>
lua中的代码:
MyFrame:SetMovable(true) MyFrame:RegisterForDrag("LeftButton") MyFrame:SetScript("OnDragStart", function() if arg1 == "LeftButton" then MyFrame:StartMoving() end end) MyFrame:SetScript("OnDragStop", function() MyFrame:StopMovingOrSizing() end) MyFrame:SetScript("OnMouseDown", function() MyFrame:SetClampedToScreen(true) end)
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/yidong/11524.html