Thread Tools Display Modes
04-01-15, 12:52 PM   #1
Basil2
An Aku'mai Servant
Join Date: Feb 2015
Posts: 30
Can I make options dialog by using code?

I need to create window with several checkboxes (like PowerAuras options dialog but simplier). I expected to do this using CreateFrame(), but the following code doesn't work at all:

Code:
function OpenSettingsFrame()
    local f = RecommendOptionsFrame -- this frame is defined in xml file
    f:Show()
    
    CreateFeatureLine(f, RcmSettings.Riptide)
    CreateFeatureLine(f, RcmSettings.Surge)
end

function CreateFeatureLine(parent, feature)
    f = CreateFrame("FontString ", nil, parent)
    f:Show()
    f:SetText(feature.Name)
    for k, v in pairs(feature.Values) do
        CreateCheckbox(f, v, UseTypeNames[k])
    end
end

function CreateCheckbox(parent, value, ttp)
    b = CreateFrame("CheckButton", nil, parent)
    b:Show()
    b:SetChecked(value)
    b.tooltip = ttp;
end
First of all, CreateFrame("FontString") fails - it writes "Unknown frame type 'FontString'". I am a bit surprised - I expected that every type of xml frame can be created via code.

Second, if I change "FontString" just to "Frame", the code generates no errors but doesn't work - checkboxes do not appear. At the same time, RecommendOptionsFrame is shown correctly (I see it on screen).

And third, I have questions :

1. How to make frame with text using code?
2. Why checkboxes don't appear?
3. Which addon does create its GUI using code? (that I can inspect).

Last edited by Basil2 : 04-01-15 at 01:40 PM.
  Reply With Quote
04-01-15, 02:11 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Font strings are not "frames", but "regions", and they're created differently, using frame:CreateFontString().

Frames are essentially no more than anchor points as far as visuals go. You need to somehow use textures to get something visible.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
04-01-15, 02:17 PM   #3
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Why not check and see how "PowerAuras" does this? Actually, you can check quite a few addons that have an option screen. Many addons now use an option screen in the "AddOns" tab of Blizzard's default options.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!
  Reply With Quote
04-02-15, 01:37 AM   #4
Basil2
An Aku'mai Servant
Join Date: Feb 2015
Posts: 30
Originally Posted by jeffy162 View Post
Why not check and see how "PowerAuras" does this? Actually, you can check quite a few addons that have an option screen.
PowerAuras does this by using XML, which I am trying to avoid I watched several addons with dialog window but all of them used XML.
  Reply With Quote
04-02-15, 02:11 AM   #5
Basil2
An Aku'mai Servant
Join Date: Feb 2015
Posts: 30
Originally Posted by Lombra View Post
Font strings are not "frames", but "regions", and they're created differently, using frame:CreateFontString().

Frames are essentially no more than anchor points as far as visuals go. You need to somehow use textures to get something visible.
Thank you for guidance, I changed code to following:

Code:
f = RecommendOptionsFrame:CreateFontString("abc", "OVERLAY", "GameFontNormal")
f:Show()
f:SetText("12345555664dfgfdg")
However, text doesn't apear on frame Same XML code works perfectly

Code:
    <Layers>
      <Layer level="OVERLAY">
        <FontString name="OptionsString" inherits="GameFontNormal" text="Recommend options">
        </FontString>
      </Layer>
    </Layers>
  Reply With Quote
04-02-15, 02:58 AM   #6
odjur84
A Fallenroot Satyr
 
odjur84's Avatar
Join Date: Jan 2015
Posts: 24
Hi!

It seems that you haven't anchored the FontString-object to anything. Try something like

Code:
f:SetPoint("CENTER",nil,"CENTER",0,0)
Cheers,

Odjur
  Reply With Quote
04-02-15, 08:15 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Also, you have to explicitly tell it to be shown. Frames/regions are shown by default when created.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
04-03-15, 03:19 AM   #8
Basil2
An Aku'mai Servant
Join Date: Feb 2015
Posts: 30
Originally Posted by odjur84 View Post
Hi!
It seems that you haven't anchored the FontString-object to anything. Try something like
It works after this, thank you much for help!

I also discovered why my checkboxes don't appear - I forgot to add 4-th function parameter: template.
  Reply With Quote
04-03-15, 02:52 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
If you don't want your objects to inherit from a pre-defined template, then you're going to have to do that work on your own. (Size, position, texture, font, etc.)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Can I make options dialog using code?

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