View Single Post
05/06/15, 03:00 AM   #4
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 578
Originally Posted by Glen348 View Post
Thanks a lot, I hate xml :P


just some notes:
ZO_ObjectPool_CreateControl is simply a shortcut to CreateControlFromVirtual which abuses TemplateName as NamePrefix:
Lua Code:
  1. function ZO_ObjectPool_CreateControl(templateName, objectPool, parentControl)
  2.     return CreateControlFromVirtual(templateName, parentControl, templateName, objectPool:GetNextControlId())
  3. end
So this may better:
Lua Code:
  1. local button = CreateControlFromVirtual("NotebookIndex", notebook.toc.scrollChild, "ZO_DefaultTextButton", indexPool:GetNextControlId())
CreateControlFromVirtual just does:
Lua Code:
  1. local button = WINDOW_MANAGER:CreateControlFromVirtual("NotebookIndex" .. indexPool:GetNextControlId(), notebook.toc.scrollChild, "ZO_DefaultTextButton")

By the way: Is "NotebookIndex" really unique enough?
Another thing you should ask yourself is: Why using a pool instance and counting on your own with buttonCount?
If you want to chain controls in a loop you may change the whole construct to use a variable "lastControl" which remembers the previous button to anchor to.
Why recreating the control's names and look into the global instead of saving a reference to the "right" button in notebook.selectedpage.button
And what, if this button already exists?

Good luck
  Reply With Quote