Quantcast
SetScript OnMouseDown for a clickable text-only Frame? - WoWInterface
Thread Tools Display Modes
12-24-20, 01:27 PM   #1
Krainz
A Wyrmkin Dreamwalker
Join Date: Oct 2016
Posts: 57
SetScript OnMouseDown for a clickable text-only Frame?

Hello, I'm tinkering with this code to make a clickable "Great Vault" text that opens the Weekly Vault

However, when I click the text, the OnMouseDown script doesn't happen. What am I doing wrong?

Lua Code:
  1. local f = CreateFrame("Frame", nil, UIParent)
  2. f:SetWidth(1)
  3. f:SetHeight(1)
  4. f:SetPoint("CENTER", 0, 0)
  5. local t = f:CreateFontString(f, "OVERLAY", "GameTooltipText")
  6. t:SetPoint("CENTER", 0, 0)
  7. t:SetText("Great Vault")
  8.  
  9. f:SetScript("OnMouseDown", function (self, button)
  10.     if button=='LeftButton' then
  11.         LoadAddOn("Blizzard_WeeklyRewards");
  12.         WeeklyRewardsFrame:Show()
  13.     end
  14. end)

Also, there's a XIV_Databar frame. I'd like to make that "Great Vault" frame's position relative to the XIV_Databar's position. How do I do it?
  Reply With Quote
12-24-20, 02:45 PM   #2
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 975
Try increasing the width and height to something bigger than 1 pixel
  Reply With Quote
12-24-20, 03:02 PM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,340
Lua Code:
  1. local f = CreateFrame("Frame", nil, UIParent)
  2. local t = f:CreateFontString(f, "OVERLAY", "GameTooltipText")
  3. t:SetText("Great Vault")
  4. f:SetSize(t:GetSize())
  5. t:SetPoint("CENTER")
  6. f:SetPoint("TOP", XIV_Databar, "BOTTOM", 0, 0) -- set f position relative to XIV_Databar
  7.  
  8. f:SetScript("OnMouseDown", function (self, button)
  9.     if button=='LeftButton' then
  10.         LoadAddOn("Blizzard_WeeklyRewards");
  11.         WeeklyRewardsFrame:Show()
  12.     end
  13. end)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
12-24-20, 04:52 PM   #4
Krainz
A Wyrmkin Dreamwalker
Join Date: Oct 2016
Posts: 57
Hmmm the frame doesn't show up in my screen with that SetPoint

If I put a
Lua Code:
  1. f:SetPoint("CENTER")

it works just fine, but of course I don't want it in the center of my screen.

I tried adding

Lua Code:
  1. local XIV_Databar = XIV_Databar

On the beginning of the code, as XIV_Databar is a frame created by another addon, to no avail.

I also tested in game by running /run XIV_Databar:Hide() and that frame became hidden as intended.

What am I missing?

Also, thanks for all the help and a very merry Christmas to you all!


EDIT:

lua Code:
  1. f:SetPoint("CENTER", XIV_Databar, "BOTTOM", 100, 0) -- set f position relative to XIV_Databar

This worked! Apparently all I needed to do was to move it to "CENTER". Thanks!

Last edited by Krainz : 12-24-20 at 04:57 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SetScript OnMouseDown for a clickable text-only Frame?

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