• 0

    posted a message on Help with Button Text and Tooltips
    Quote from Xchg
    I see, so I use b3:SetFontString(fs) when I'm creating the button to make it the default fontstring.


    Although this does what I asked, I guess it's not what I wanted. It makes the text behave like a button text (ie, it moves as if being depressed).

    Is the best practice to create a frame to house your widget components and a label, always calling your label your form name plus 'Text'?

    For example, the buttons and sliders I made have labels that I can change their text. Now I'm on editboxes, which have no labels, so I created a form to house my editbox plus my own label, calling the form EditBox1 and the label EditBox1Text.

    I can't seem to find any addons to look at to see how people normally do this. Most of my addons seem to make use of libs to handle their UIs, so it's hard to see what's going on.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Help with Button Text and Tooltips
    I see, so I use b3:SetFontString(fs) when I'm creating the button to make it the default fontstring.

    Thanks!
    Posted in: Lua Code Discussion
  • 0

    posted a message on Help with Button Text and Tooltips
    Ok, so I'm trying to learn how to make all the UI elements and I'm stuck on buttons.

    I've got this in the beginning to handle my tooltips. I'm grabbing the button's text as the tooltip 'header' and the rest as an additional line.

    function OnEnter(self, motion)
    	GameTooltip:SetOwner(self, "ANCHOR_TOP")
    	GameTooltip:SetText(getglobal(self:GetName().."Text"):GetText())
    	GameTooltip:AddLine(tostring(self.tooltipText), 1, 1, 1)
    	GameTooltip:Show()
    end
    
    function OnLeave(self, motion)
    	GameTooltip:Hide()
    end



    Creating a button from the template was easy. I can SetText() and GetText() to manipulate the button's text.

    b1 = CreateFrame("Button", "myButton1", UIParent, "OptionsButtonTemplate")
    b1:SetPoint("CENTER")
    [B]b1:SetText("Test Button 1")[/B]
    b1.tooltipText = "This is an options button"
    b1:SetScript("OnClick", function(self, button, down) print(self:GetName()) end)
    b1:SetScript("OnEnter", OnEnter)
    b1:SetScript("OnLeave", OnLeave)



    I was even able to create a checkbox, except now I have to reference the button's name and 'Text', but that's ok.

    b2 = CreateFrame("CheckButton", "myCheckButton2", UIParent, "OptionsCheckButtonTemplate")
    b2:SetPoint("LEFT")
    [B]getglobal(b2:GetName().."Text"):SetText("Test CheckButton 2")[/B]
    b2.tooltipText = "This is a checkbutton"
    b2:SetScript("OnClick", function(self, button, down) print(self:GetName()) end)
    b2:SetScript("OnEnter", OnEnter)
    b2:SetScript("OnLeave", OnLeave)



    Now for my custom button without a template, I'm confused how I'm supposed to define the fontstring. Do I just give it the same name as my button plus 'Text' to follow the same naming convention as the checkbutton?

    b3 = CreateFrame("Button", "myButton3", UIParent)
    
    local t = b3:CreateTexture()
    t:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark")
    t:SetWidth(16)
    t:SetHeight(16)
    t:SetPoint("LEFT")
    b3.texture = t
    
    local fs = b3:CreateFontString("myButton3[B]Text[/B]", nil, "GameFontNormal")
    fs:SetText("Test Button 3")
    fs:SetPoint("LEFT",24,0)
    b3.text = fs
    
    b3:SetPoint("Right")
    b3:SetWidth(128)
    b3:SetHeight(16)
    b3.tooltipText = "This is a custom button"
    b3:SetScript("OnClick", function(self, button, down) print(self:GetName()) end)
    b3:SetScript("OnEnter", OnEnter)
    b3:SetScript("OnLeave", OnLeave)



    In game, I can type /run b1:SetText("TEST1") and the button updates to reflect the change.

    I can type /run myButton1Text:SetText("TEST2") and again the same.
    But when I type /run b3:SetText("TEST3") nothing happens. I can type /run print(b3:GetText()) and I get TEST3, but the button's display text isn't updated.

    I can type /run myButton3Text:SetText("TEST4") and that works ok. So I guess my question is, am I doing this right? How do I use SetText() GetText() with this button?
    Posted in: Lua Code Discussion
  • 0

    posted a message on need some feedback on some options for my addon.
    I'm not sure how some of my addons do it (like Bartender, and others) where you can have customized profiles

    per character
    per class
    per server

    and even copy an existing profile as a template for a new profile. I like this because I have a default setting I use for all characters and then have the option of copying the profile and making minor tweaks per character.

    If this is too advanced (I'm not sure how to do it), I tend to find that I personally prefer to have the same settings per account instead of per character.
    Posted in: Addon Ideas
  • 0

    posted a message on "Find the healers" PVP addon
    I'm not an expert with addons but I'll give this a shot.

    http://wow.curse.com/downloads/wow-addons/details/findthehealers.aspx
    Posted in: Addon Ideas
  • To post a comment, please or register a new account.