View Single Post
07-25-22, 08:34 PM   #1
Tinypower
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jul 2022
Posts: 2
<OnLoad> element makes my little window invisible

So I have the following XML file. If I remove the line in red, the window appears alright---but it does not respond to mouse drag. If I keep this line, the window is invisible, but I can drag it---I know it because the close button can still be seen. What is causing this problem and how do I fix it?

Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<Frame name="BCHFrame" parent="UIParent" movable="true" enableMouse="true" inherits="BackdropTemplate" toplevel="true">
		<!--Anchors is a property element-->
		<Anchors>
			<!-- An anchor can be created with frame:SetPoint() method-->
			<Anchor point="LEFT" relativePoint="CENTER">
				<Offset>
					<AbsDimension x="150" y="0" />
				</Offset>
			</Anchor>
		</Anchors>
		
		<Size>
			<AbsDimension x="200" y="150" />
		</Size>
		<KeyValues>
			<!-- a list of backdropInfo: https://www.townlong-yak.com/framexml/live/Backdrop.lua -->
			<KeyValue key="backdropInfo" value="BACKDROP_DIALOG_32_32" type="global" />
		</KeyValues>
		<!-- Backdrop is now only available to frames that inherits backdrop template, and must only use BackdropInfo -->
		<!-- <Backdrop 
		bgFile="Interface\DialogFrame\UI-DialogBox-Background"
		tile="true"
		edgeFile="Interface\DialogFrame\UI-DialogBox-Border">
			<TileSize>
				<AbsValue val="32"/>
			</TileSize>
			<EdgeSize>
				<AbsValue val="32"/>
			</EdgeSize>
			<BackgroundInsets>
				<AbsInset left="11" right="12" top="12" bottom="11"/>
			</BackgroundInsets>
		</Backdrop> -->
		<Scripts>
			<OnLoad>self:RegisterForDrag("LeftButton")</OnLoad>
			<OnDragStart>self:StartMoving()</OnDragStart>
			<OnDragStop>self:StopMovingOrSizing()</OnDragStop>
		</Scripts>
		<Frames>
			<!-- close button -->
			<Button name="$parent_CloseButton" inherits="UIPanelCloseButton">
				<Anchors>
					<Anchor point="TOPRIGHT" relativePoint="TOPRIGHT">
						<Offset>
							<AbsDimension x="0" y="0" />
						</Offset>
					</Anchor>
				</Anchors>
			</Button>
		</Frames>
		
	</Frame>
</Ui>
Also, if I remove the line, but instead type in game:
Code:
/run BCHFrame:RegisterForDrag("LeftButton")
then everything seems running alright

Last edited by Tinypower : 07-25-22 at 08:38 PM.
  Reply With Quote