Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-09-19, 11:32 PM   #1
urakkaamyx
A Murloc Raider
Join Date: May 2019
Posts: 8
TitleRegion - Movable Frame on TitleFrame only

Issue: Cant seem to get TitleRegion to work. Making Frame movable via Title Frame only
Method: XML: Using Template Frames. lua on the event of OnMouseDown/OnMouseUp.

I can get the whole frame to drag around by doing the OnMouseDown/OnMouseUp events if i place it in my root <Frame />, Which is fine except i dont want it to drag the frame unless im clicking on the title frame

Im wandering, can i set the OnMouseDown/OnMouseUp events in the TitleFrame template in order to accomplish what im after? or does that not work?.

code:
Main Frame (Called Via CreateFrame())
iTrackerFrameTemplate.xml
Code:
<Ui>
    <Script file="iTrackerFrameTemplate.lua" />
    <Frame name="iTrackerFrameTemplate" virtual="true">
        <Size x="200" y="292" />
        <Anchors>
            <Anchor point="CENTER" relativeTo="UIParent" relativePoint="CENTER" />
        </Anchors>
        <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="" tile="true">
            <BackgroundInsets>
                <AbsInset left="11" right="12" top="12" bottom="11" />
            </BackgroundInsets>
            <TileSize val="32" />
            <EdgeSize val="32" />
        </Backdrop>
        <Frames>
            <Frame name="$parent_TitleFrame" parentKey="titleFrame" inherits="iTrackerFrame_TitleFrameTemplate">
                <Scripts>
                    <OnLoad>
                        iTrackerFrame_TitleFrameTemplate_OnLoad_SetWidth(self)
                    </OnLoad>
                </Scripts>
            </Frame>
        </Frames>
    </Frame>
</Ui>
iTrackerFrame_TitleFrameTemplate.xml
Code:
<Ui>
    <Script file="iTrackerFrame_TitleFrameTemplate.lua" />
    <Frame name="iTrackerFrame_TitleFrameTemplate" parentKey="titleFrame" virtual="true" movable="true">
        <Size x="80" y="50" />
        <Anchors>
            <Anchor point="TOPRIGHT" relativeTo="$parent" relativePoint="TOPRIGHT" y="20" />
        </Anchors>
        <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background-Dark" edgeFile="" tile="true">
            <BackgroundInsets>
                <AbsInset left="11" right="12" top="12" bottom="11" />
            </BackgroundInsets>
            <TileSize val="32" />
            <EdgeSize val="32" />
        </Backdrop>
        <Layers>
            <Layer level="OVERLAY">
                <FontString name="title" parentKey="title" inherits="GameFontNormal" text="&lt;title&gt;">
                    <Size x="80" y="20" />
                    <Anchors>
                        <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT" />
                        <Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT" />
                    </Anchors>
                </FontString>
            </Layer>
        </Layers>
    </Frame>
</Ui>
The only Script in that file atm.
iTrackerFrameTemplate.lua

Code:
function iTrackerFrame_TitleFrameTemplate_OnLoad_SetWidth(Frame)
    -- Set Width Based on title length
    local title = Frame.title
    title:SetText(iTracker:GetInfo('AppName'))
    Frame:SetWidth(title:GetWidth())
end
-- iTracker:GetInfo() just gets a data from a simple table when the Addon is loaded (Based on some settings I have a dev-local, and dev-game, and game (local loads up the project for external debugging. game uses the ingame/addon debugging .. and game is live and a few other various ease of information access.))

you can just set that to "TITLE OF FRAME" if you want.

Last edited by urakkaamyx : 05-09-19 at 11:36 PM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » TitleRegion - Movable Frame on TitleFrame only


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off