View Single Post
Unread 02-13-13, 06:42 PM   #22
gmarco
A Flamescale Wyrmkin
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 100
Zork your code is really cool but surely too much complex for a newbie programmer like me :-)

Slowly I have finished my alpha version of the addons, but I am plenty of questions. So I try to ask for finding more help.

I upload a picture which represent a ganklist. I'd like to click on a name, this set the text in the text input and then I can press del to delete it from the list or add a new name to it.

Now I'd like to ask.

1) in the frame I have created I have the button text that are "centered" ... I am trying to let them left justify but none of the methods I used till now seems to work.

2) Is possible to let the buttons to react to the OnClick event ? Something like:
button:SetScript("OnClick", function() ... bla bla

3) Is possible to have the scrollframe "bordered" like the input box below ?

4) How can I make a orizontal bar for divide the zones of a frame ?


The code is now:

Lua Code:
  1. -- Configuration Panel -------------------------------------------------------------------------------------
  2.  
  3. local options = CreateFrame("Frame", ADDON.."Options", InterfaceOptionsFramePanelContainer)
  4. options.name = GetAddOnMetadata(ADDON, "Title") or ADDON
  5. InterfaceOptions_AddCategory(options)
  6.  
  7. local title = options:CreateFontString("$parentTitle", "ARTWORK", "GameFontNormalLarge")
  8. title:SetPoint("TOPLEFT", 16, -16)
  9. title:SetText(options.name)
  10. options.title = title
  11.  
  12. local subtext = options:CreateFontString("$parentSubText", "ARTWORK", "GameFontHighlightSmall")
  13. subtext:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
  14. subtext:SetPoint("RIGHT", -32, 0)
  15. subtext:SetHeight(32)
  16. subtext:SetJustifyH("LEFT")
  17. subtext:SetJustifyV("TOP")
  18. subtext:SetText(GetAddOnMetadata(ADDON, "Notes"))
  19. options.subtext = subtext
  20.  
  21. local enable = CreateFrame("CheckButton", "$parentEnable", options, "InterfaceOptionsCheckButtonTemplate")
  22. enable:SetPoint("TOPLEFT", subtext, "BOTTOMLEFT", -2, -8)
  23. enable.Text:SetText(ENABLE)
  24. enable.tooltipText = "Enable monitoring"
  25. enable:SetChecked(REMGANK_ENABLE);
  26. enable:SetScript("OnClick", function(self)
  27.    
  28.     if enable:GetChecked() then
  29.         REMGANK_ENABLE = 1
  30.         print(string_format("%s: is enabled", prgname))
  31.         frame_cleu:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  32.     else
  33.         REMGANK_ENABLE = 0
  34.         print(string_format("%s: is disabled",prgname))
  35.         frame_cleu:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  36.     end
  37.    
  38. end)
  39.  
  40.  -- Add button
  41. local RemGank_Add_Player_Button = CreateFrame("button","RemGank_Add_Player_Button", options, "UIPanelButtonTemplate")
  42. RemGank_Add_Player_Button:SetHeight(25)
  43. RemGank_Add_Player_Button:SetWidth(50)
  44. RemGank_Add_Player_Button:SetPoint("BOTTOMRIGHT", options, "BOTTOMRIGHT", -12, 12)
  45. RemGank_Add_Player_Button:SetText("Add")
  46. RemGank_Add_Player_Button:SetScript("OnClick",
  47.     function()
  48.  
  49.     end)
  50.    
  51. -- Del Button
  52. local RemGank_Del_Player_Button = CreateFrame("button","RemGank_Del_Player_Button", options, "UIPanelButtonTemplate")
  53. RemGank_Del_Player_Button:SetHeight(25)
  54. RemGank_Del_Player_Button:SetWidth(50)
  55. RemGank_Del_Player_Button:SetPoint("BOTTOMRIGHT", options, "BOTTOMRIGHT", -72, 12)
  56. RemGank_Del_Player_Button:SetText("Del")
  57. RemGank_Del_Player_Button:SetScript("OnClick",  
  58.     function()  
  59.    
  60.     end)
  61.  
  62. -- Text Input
  63. local RemGank_Input_eb2 = CreateFrame("EditBox","eb2",options,"InputBoxTemplate")
  64. RemGank_Input_eb2:SetMaxLetters(15)
  65. RemGank_Input_eb2:SetFont(framefontn,framefonth)
  66. RemGank_Input_eb2:SetAutoFocus(disable)
  67. RemGank_Input_eb2:SetSize(192, 24)
  68. RemGank_Input_eb2:SetPoint("BOTTOMRIGHT", options, "BOTTOMRIGHT", -132, 12)
  69.  
  70. local scrollFrame = CreateFrame("ScrollFrame", "MyFirstNotReallyScrollFrame", options, "FauxScrollFrameTemplate")
  71. scrollFrame:SetWidth(BUTTON_WIDTH * 3)
  72. scrollFrame:SetHeight(NUM_BUTTONS * BUTTON_HEIGHT)
  73. scrollFrame:SetPoint("BOTTOMRIGHT", options, "BOTTOMRIGHT", -38, 64)
  74. scrollFrame:EnableMouse(true)
  75. scrollFrame:SetScript("OnDragStart", function(self) self:StartMoving() end)
  76. scrollFrame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
  77. scrollFrame:Show()
  78.  
  79. scrollFrame:SetScript("OnVerticalScroll", function(self, offset)
  80.     FauxScrollFrame_OnVerticalScroll(self, offset, BUTTON_HEIGHT, RemGank_ListFrame_Update(self))
  81. end)
  82.  
  83. for i = 1, NUM_BUTTONS do
  84.     local button = CreateFrame("Button", nil, scrollFrame:GetParent())
  85.     if i == 1 then
  86.         button:SetPoint("TOP", scrollFrame)
  87.     else
  88.         button:SetPoint("TOP", buttons[i - 1], "BOTTOM")
  89.         -- button:SetPoint("TOP", buttons[i - 1],  "LEFT", 0, 0)
  90.     end
  91.     button:SetNormalFontObject("GameFontNormal")
  92.     button:SetSize(BUTTON_WIDTH, BUTTON_HEIGHT)
  93.     button:SetText(RemGankLS[i])
  94.     button:SetScript("OnClick",  function()
  95.         RemGank_Input_eb2:SetText(RemGankLS[i])
  96.     end)
  97.     buttons[i] = button
  98. end
  99.  
  100. -- Updating ?
  101. print ("DEBUG: Force updating")
  102. RemGank_ListFrame_Update(scrollFrame)
  103.  
  104. function options.refresh()
  105.     enable:SetChecked(REMGANK_ENABLE)
  106.     RemGank_ListFrame_Update(scrollFrame)
  107. end
  108.  
  109. if LibStub and LibStub("LibAboutPanel", true) then
  110.     options.about = LibStub("LibAboutPanel").new(options.name, ADDON)
  111. end

Thanks again to all for your attention
Attached Thumbnails
Click image for larger version

Name:	remganklist.png
Views:	231
Size:	78.8 KB
ID:	7566  
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
gmarco is offline   Reply With Quote