View Single Post
09-13-20, 12:18 AM   #1
maqjav
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Feb 2012
Posts: 60
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
And my template:
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>
Thanks.
  Reply With Quote