Quantcast TitleRegion - Movable Frame on TitleFrame only - WoWInterface
Thread Tools Display Modes
05-09-19, 11:32 PM   #1
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?.

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

function iTrackerFrame_TitleFrameTemplate_OnLoad_SetWidth(Frame)
    -- Set Width Based on title length
    local title = Frame.title
-- 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
05-10-19, 12:19 AM   #2
I did that?
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,154
More like:
Lua Code:
  1. <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/">
  2.     <Script file="Some.lua" />
  4.     <Frame name="iTrackerBodyFrameTemplate" virtual="true">
  5.         <Anchors>
  6.             <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="BOTTOMLEFT"/>
  7.             <Anchor point="TOPRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT"/>
  8.         </Anchors>
  9.         <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="" tile="true">
  10.             <BackgroundInsets>
  11.                 <AbsInset left="0" right="0" top="0" bottom="0" />
  12.             </BackgroundInsets>
  13.             <TileSize val="32" />
  14.             <EdgeSize val="32" />
  15.         </Backdrop>
  16.         <Scripts>
  17.             <OnLoad>
  18.                 iTrackerFrame_TitleFrameTemplate_OnLoad_SetWidth(self)
  19.             </OnLoad>
  20.         </Scripts>
  21.     </Frame>
  23.     <Frame name="iTrackerFrame_TitleFrameTemplate" virtual="true" movable="true">
  24.         <Size x="200" y="20" />
  25.         <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background-Dark" edgeFile="" tile="true">
  26.             <BackgroundInsets>
  27.                 <AbsInset left="0" right="0" top="0" bottom="0" />
  28.             </BackgroundInsets>
  29.             <TileSize val="32" />
  30.             <EdgeSize val="32" />
  31.         </Backdrop>
  32.         <Layers>
  33.             <Layer level="OVERLAY">
  34.                 <FontString name="title" parentKey="title" inherits="GameFontNormal" text="&lt;title&gt;">
  35.                     <Anchors>
  36.                         <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT" />
  37.                         <Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT" />
  38.                     </Anchors>
  39.                 </FontString>
  40.             </Layer>
  41.         </Layers>
  42.         <Frames>
  43.             <Frame name="$parent_BodyFrame" parentKey="body" inherits="iTrackerBodyFrameTemplate" />
  44.         </Frames>
  45.         <Scripts>
  46.             <OnLoad>
  47.                 self:EnableMouse(true)
  48.                 self:RegisterForDrag("LeftButton")
  49.             </OnLoad>
  50.             <OnDragStart>
  51.                 self:StartMoving()
  52.             </OnDragStart>
  53.             <OnDragStop>
  54.                 self:StopMovingOrSizing()
  55.             </OnDragStop>
  56.         </Scripts>
  57.     </Frame>
  59.     <Frame name="FizzTrack" parent="UIParent"  inherits="iTrackerFrame_TitleFrameTemplate">
  60.         <Anchors>
  61.             <Anchor point="CENTER" relativeTo="UIParent" relativePoint="CENTER" />
  62.         </Anchors>
  63.     </Frame>
  64. </Ui>

Lua Code:
  1. function iTrackerFrame_TitleFrameTemplate_OnLoad_SetWidth(Frame)
  2.     -- Set desired height
  3.     title:SetText("Some Name")
  4.     Frame:SetHeight(300)
  5. end

The width of the body will size with the header and its height can be set independently so the function name is now a bit misleading, more like

Edited: so the background insets and anchors don't overlay and darken the text.
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-10-19 at 12:42 AM.
  Reply With Quote
05-10-19, 05:53 AM   #3
A Murloc Raider
Join Date: May 2019
Posts: 8
Thanks :)

First off, Thanks for replying

THANK you so much. I was a little confused as to the whole width height thing, but once i pasted your code in and gave it a test i figured out what was going on.. Thank you again. ^_^
  Reply With Quote

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

Thread Tools
Display Modes

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