09-13-20, 12:18 AM | #1 |
World map overlay frame and SetMovable
Hello.
I'm adding a new overlay frame to my world map that contains one frame. I'm trying to allow the user to move this frame on drag and drop. The problem I'm finding is that if the frame is not movable, whenever I minimize/maximize the world map my frame adapts to the world map container correcly remaining in the correct position, but as soon as I make it movable, the frame detaches from the world map and it doesn't adapt anymore, so if in the maximized version it appears in the top right corner of the map, in the minimize version it appears on top of my minimap. Is it posible to keep my frame inside the world map and maintain the last position while maximized/minimized? This is my code: Code:
WorldMapFrame:AddOverlayFrame("MyTemplate", "FRAME", "CENTER", WorldMapFrame:GetCanvasContainer(), "TOP", 0, 0); MyTemplateMixin = { }; function MyTemplateMixin:OnLoad() self.MyFrame:SetMovable(true) self.MyFrame:RegisterForDrag("LeftButton") self.MyFrame:SetScript("OnDragStart", function(self) self:StartMoving() end) self.MyFrame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) end function MyTemplateMixin:Refresh() end MyFrameMixin = { } function MyFrameMixin:OnMouseEnter() end function MyFrameMixin:OnMouseLeave() end Code:
<?xml version="1.0"?> <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd"> <Script file="MyTemplateMixin.lua"/> <Frame name="MyTemplate" frameStrata="HIGH" mixin="MyTemplateMixin" virtual="true"> <Size x="175" y="32" /> <Frames> <Frame parentKey="MyFrame" mixin="MyFrameMixin"> <Size> <AbsDimension x="175" y="32"></AbsDimension> </Size> <Anchors> <Anchor point="CENTER"/> </Anchors> <Layers> <Layer level="BACKGROUND"> <Texture file="Interface\ChatFrame\UI-ChatInputBorder-Left"> <Size> <AbsDimension x="75" y="32"></AbsDimension> </Size> <Anchors> <Anchor point="LEFT"> <Offset> <AbsDimension x="-15" y="0"></AbsDimension> </Offset> </Anchor> </Anchors> </Texture> </Layer> </Layers> <Scripts> <OnEnter method="OnMouseEnter"/> <OnLeave method="OnMouseLeave"/> </Scripts> </Frame> </Frames> <Scripts> <OnLoad method="OnLoad" /> </Scripts> </Frame> </Ui> |
|
09-17-20, 08:15 PM | #2 |
If you are trying to build an overlay over the entire map frame (its borders, UI elements, etc.), then something like this might help:
Lua Code:
If you are trying to build something on the map canvas itself which appears at an x/y coordinate and can be dragged to another x/y coordinate, then you should take a look at MapCanvas_DataProviderBase.lua. Lua Code:
XML Code:
toc Code:
Disclaimer: I just quickly wrote this together by taking snippets of a much longer file. I'm probably missing something to make it work. |
|
WoWInterface » Developer Discussions » Lua/XML Help » World map overlay frame and SetMovable |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|