Download
(8 Kb)
Download
Updated: 03/13/23 03:24 PM
Pictures
File Info
Compatibility:
Scribes of Fate (8.3.5)
Firesong (8.2.5)
Updated:03/13/23 03:24 PM
Created:07/11/15 10:51 AM
Monthly downloads:24,945
Total downloads:4,305,740
Favorites:1,945
MD5:
LibCustomMenu  Popular! (More than 5000 hits)
Version: 7.2.1
by: votan [More]
Info
This library is for addon developers. Download it, if an addon dependency tells you so.

Description
This library is written to overcome one way to get the "Access a private function XYZ from insecure code". But beginning with version 2.0, it does additional provide a new feature: sub menus.
Beginning with version 3.0, it does additional provide a new feature: divider.

Background
Controls, created from add-on code (as part of code path) are marked as "insecure/compromissed".
Functions, which have no problem with been called from "insecure" controls, are still working perfectly.
Like those of add-ons or Show On Map, Link in Chat or Get Help.
But "secured" functions like UseItem, InitiateDestroy, PickupInventoryItem raising the error message from above.
Once you hook AddMenuItem ALL controls created for the context-menu are "insecure".

Prior to ESO 2.0.13 if an add-on offers a full custom context-menu (no built-in menu entries) and this context-menu is shown first after (re-)load UI the first menu item controls are insecure. A crash of "Use" in the inventory afterwards was guaranteed.
Starting with ESO 2.0.13 ZOS preallocates 10 "secure" menu items. See here.
But this just reduces the chance of running into that problem, it does not fix it.
Currently the number of preallocated controls is 30. Running into this problem with AddMenuItem is real rare, but inventory action slots still don't like custom menu entries.

To avoid the error message, the controls of built-in menu items and add-on menu items must be strictly separated. That's what AddCustomMenuItem of this library does. It uses an own pool of controls, which look exactly the same. Sounds strange, but works.

I don't use private functions. Why should I use this lib?
It's not you, who uses private functions. It is built-in code, which re-uses controls indirectly created by your add-on in AddMenuItem.

I want to use this lib, so what to do?
After you have included the lib in your add-on manifest (.txt) do a text search for the global function AddMenuItem (not any :AddMenuItem of other objects) and replace it with AddCustomMenuItem.
Be careful with a simple "Replace All" over all files! You probably replace the AddMenuItem of LibCustomMenu itself

Version 1.0
This version was intended as proof of concept, but was successfully used in Beartram's FCO Item Saver, Circonian's FilterIt and my Fish Fillet.

Version 2.0
In order to have more value than avoiding a rare, just annoying "bug", sirinsidiator suggested and provided proof of concept code for sub menu items.
A big thank to sirinsidiator!
I finalized it and here we are.

API 2.0
function AddCustomMenuItem(mytext, myfunction, itemType, myfont, normalColor, highlightColor, itemYPad)

Fully compatible with AddMenuItem.
mytext: string, required. Caption of menu item.
myfunction: function(), required. Called if clicked.
itemType: int, optional. MENU_ADD_OPTION_LABEL or MENU_ADD_OPTION_CHECKBOX. Default MENU_ADD_OPTION_LABEL.
myfont: string, optional.
normalColor: ZO_ColorDef, optional. Color of unselected item.
highlightColor: ZO_ColorDef, optional. Color of selected/hovered item.
itemYPad: int, optional. y-padding between items.


function AddCustomSubMenuItem(mytext, entries, myfont, normalColor, highlightColor, itemYPad, subMenuButtonCallbackFunc)

mytext: string, required. Caption of menu item.
entries: table of sub items or callback returning table of sub items, required.
myfont: string, optional.
normalColor: ZO_ColorDef, optional. Color of unselected/normal sub item.
highlightColor: ZO_ColorDef, optional. Color of selected/hovered sub item.
itemYPad: int, optional. y-padding between sub items.
subMenuButtonCallbackFunc: function, optional. Callback function for the click on the submenu open button (the one at the main menu showing the submenu)

sub item:
label: string or function(rootMenu, childControl), required.
callback: function(), required.
disabled: boolean or function(rootMenu, childControl), optional. Default false. if true, sub item is visible, but gray and not clickable.
visible: boolean or function(rootMenu, childControl), optional. Default true.

These examples are for self-created menus. If you want to add items to the inventory context-menu, look at the example for LibCustomMenu:RegisterContextMenu more below.

example 1:
Lua Code:
  1. local entries = {
  2.   {
  3.     label = "Test 1",
  4.     callback = function() d("Test 1") end,
  5.   },
  6.   {
  7.     label = "Test 2",
  8.     callback = function() d("Test 2") end,
  9.     disabled = function(rootMenu, childControl) return true end,
  10.   }
  11. }
  12. ClearMenu()
  13. AddCustomSubMenuItem("Sub Menu", entries)
  14. ShowMenu()

example 2:
Lua Code:
  1. local function GetEntries(rootMenu)
  2. d("run")
  3. return {
  4.   {
  5.     label = function() return GetTimeStamp() end,
  6.     callback = function() d("Test 1") end,
  7.   },
  8.   {
  9.     label = "Test 2",
  10.     callback = function() d("Test 2") end,
  11.     disabled = function(rootMenu, childControl) return true end,
  12.   }
  13. }
  14. end
  15. ClearMenu()
  16. AddCustomSubMenuItem("Sub Menu", GetEntries)
  17. ShowMenu()
If you have Notebook or ZAM Notebook, you could copy&paste the scripts from above and execute them.

API 3.0
In addition to API 2.0:
Allow divider by setting member label to a static "-". Suggested by Beartram.

example:
Lua Code:
  1. local entries = {
  2.   {
  3.     label = "Test 1",
  4.     callback = function() d("Test 1") end,
  5.   },
  6.   {
  7.     label = "-",
  8.   },
  9.   {
  10.     label = "Test 2",
  11.     callback = function() d("Test 2") end,
  12.     disabled = function(rootMenu, childControl) return true end,
  13.   }
  14. }
  15. ClearMenu()
  16. AddCustomSubMenuItem("Sub Menu", entries)
  17. ShowMenu()

API 4.1
In addition to API 3.0:
actionSlots:AddCustomSlotAction(actionStringId, actionCallback, actionType, visibilityFunction, options)

for example while hooking ZO_InventorySlot_DiscoverSlotActionsFromActionList(inventorySlot, slotActions)
for example within the callback of API 6.0. See below.

API 5.0
In addition to API 4.1+:
New entry properties itemType and checked.
itemType = MENU_ADD_OPTION_LABEL (default) or MENU_ADD_OPTION_CHECKBOX for a checkbox
checked = false/true or function() return state end
The initial checked state than opening the sub menu.

example:
Lua Code:
  1. local myState = true
  2.     local entries = {
  3.       {
  4.         label = "Test 1",
  5.         callback = function(state) myState = state df("Test 1: %s", tostring(myState)) end,
  6.         checked = function() return myState end,
  7.         itemType = MENU_ADD_OPTION_CHECKBOX,
  8.       },
  9.       {
  10.         label = "Test 1b",
  11.         callback = function() d("Test 1b") end,
  12.         itemType = MENU_ADD_OPTION_LABEL,
  13.       },
  14.       {
  15.         label = "-",
  16.       },
  17.       {
  18.         label = "Test 2",
  19.         callback = function() d("Test 2") end,
  20.         disabled = function(rootMenu, childControl) return true end,
  21.       }
  22.     }
  23.     ClearMenu()
  24.     AddCustomSubMenuItem("Sub Menu", entries)
  25.     ShowMenu()

API 6.2
In addition to API 5+:
Added callbacks, you can register to, to hook into inventory slot context menu. You don't need to reinvent the hook and are able to control the position of your entry/entries more granular.

category
lib.CATEGORY_EARLY
lib.CATEGORY_PRIMARY
lib.CATEGORY_SECONDARY
lib.CATEGORY_TERTIARY
lib.CATEGORY_QUATERNARY
lib.CATEGORY_LATE

CATEGORY_EARLY is before the first built-in menu entry.
CATEGORY_PRIMARY is after the first built-in menu entry. And so on.
CATEGORY_LATE is after built-in menu and default.

lib:RegisterContextMenu(func, category)
Register to the context menu of the inventory mouse right click.

lib:RegisterKeyStripEnter(func, category)
Register to the inventory mouse hover used to update the keybind buttons at the bottom.

func: callback function to be called.
Signature:
Lua Code:
  1. local function func(inventorySlot, slotActions)
  2. end

category: optional. defaults to CATEGORY_LATE.

lib:RegisterKeyStripExit(func)
Register to the inventory mouse hover used to update the keybind buttons at the bottom, if the mouse exits an inventory slot.

func: callback function to be called.
Signature:
Lua Code:
  1. local function func()
  2. end

example:
Lua Code:
  1. ZO_CreateStringId("SI_BINDING_NAME_SHOW_POPUP", "Show in Popup")
  2. local function AddItem(inventorySlot, slotActions)
  3.   local valid = ZO_Inventory_GetBagAndIndex(inventorySlot)
  4.   if not valid then return end
  5.   slotActions:AddCustomSlotAction(SI_BINDING_NAME_SHOW_POPUP, function()
  6.     local bagId, slotIndex = ZO_Inventory_GetBagAndIndex(inventorySlot)
  7.     local itemLink = GetItemLink(bagId, slotIndex)
  8.     ZO_PopupTooltip_SetLink(itemLink)
  9.   end , "")
  10. end
  11.  
  12. LibCustomMenu:RegisterContextMenu(AddItem, LibCustomMenu.CATEGORY_PRIMARY)

example 2:
Lua Code:
  1. local function AddItem(inventorySlot, slotActions)
  2.   local bagId, slotIndex = ZO_Inventory_GetBagAndIndex(inventorySlot)
  3.   if not CanItemBePlayerLocked(bagId, slotIndex) then return end
  4.   local locked = IsItemPlayerLocked(bagId, slotIndex)
  5.  
  6.   slotActions:AddCustomSlotAction(locked and SI_ITEM_ACTION_UNMARK_AS_LOCKED or SI_ITEM_ACTION_MARK_AS_LOCKED, function()
  7.     SetItemIsPlayerLocked(bagId, slotIndex, not locked)
  8.   end, "keybind2")
  9.   -- you can use: "primary", "secondary", "keybind1", "keybind2"
  10. end
  11.  
  12. local menu = LibCustomMenu
  13. --menu:RegisterContextMenu(AddItem, menu.CATEGORY_PRIMARY)
  14. menu:RegisterKeyStripEnter(AddItem, menu.CATEGORY_LATE)
Not really practical, because it hides the built-in keybind.
But you could use the callback just to be notified as well.

API 6.8
In addition to API 6.2+:
Added functionality to add an optional tooltip to a menu entry.
For the top level menu entries there is a new global function:
function AddCustomMenuTooltip(tooltip, index)
tooltip: Either a string shown as a simple tooltip or a callback function to let you do everything.
Signature:
Lua Code:
  1. local function func(control, inside)
  2. end
control: the menu entry control.
inside: The function is called on mouse enter with inside=true and on mouse exit with inside=false.

index: Optional. Index of the menu entry, the tooltip is for. By default the index of the last added item is used. => You call AddCustomMenuItem and when AddCustomMenuTooltip.

For sub-menus a new key "tooltip" can be used. Again it is either a string or the callback function with the signature from above.

example:
Lua Code:
  1. local myState = true
  2.     local entries = {
  3.       {
  4.         label = "Test 1",
  5.         callback = function(state) myState = state df("Test 1: %s", tostring(myState)) end,
  6.         checked = function() return myState end,
  7.         itemType = MENU_ADD_OPTION_CHECKBOX,
  8.         tooltip = "This is Test 1",
  9.       },
  10.       {
  11.         label = "Test 1b",
  12.         callback = function() d("Test 1b") end,
  13.         itemType = MENU_ADD_OPTION_LABEL,
  14.         tooltip = "This is Test 2",
  15.       },
  16.       {
  17.         label = "-",
  18.       },
  19.       {
  20.         label = "Test 2",
  21.         callback = function() d("Test 2") end,
  22.         disabled = function(rootMenu, childControl) return true end,
  23.       }
  24.     }
  25.     ClearMenu()
  26.     AddCustomSubMenuItem("Sub Menu", entries)
  27.     AddCustomMenuTooltip("A sub-menu")
  28.     AddCustomMenuItem("-", function() d("soso") end)
  29.     AddCustomMenuItem("Button", function() d("jojo") end)
  30.     AddCustomMenuTooltip(function(control, inside) if inside then d("A great button") end end)
  31.     AddCustomMenuItem("CheckBox", function() d("soso") end, MENU_ADD_OPTION_CHECKBOX)
  32.     ShowMenu()
How to use Checkbox at top level
Lua Code:
  1. local index = AddCustomMenuItem("CheckBox", function() <your callback> end, MENU_ADD_OPTION_CHECKBOX)
  2. if needToCheckIt then
  3.     ZO_CheckButton_SetChecked(ZO_Menu.items[index].checkbox)
  4. end

API 6.9
lib:EnableSpecialKeyContextMenu(key)
key: KEY_CTRL or KEY_ALT or KEY_SHIFT or KEY_COMMAND
Show an alternative context menu, if the special key is pressed while right-clicking the inventory item.

lib:RegisterSpecialKeyContextMenu(func)
Register a callback for the alternative context menu. You, the addon author, have to check which menu items you want to add for the given combination of special keys. (See signature below)
You have to enable all the keys you want to handle. See lib:EnableSpecialKeyContextMenu(key). There is no DisableSpecialKeyContextMenu, because you don't know who else had enabled them.

Signature:
Lua Code:
  1. local function func(inventorySlot, slotActions, ctrl, alt, shift, command)
  2. end
API 6.92
lib:RegisterPlayerContextMenu(func, category)
Register to the context menu of the chat player link mouse right click,

func: callback function to be called.
Signature:
Code:
local function func(playerName, rawName)
end
Category: See API 6.2 description for the available categories.

API 7.1
lib:RegisterGuildRosterContextMenu(func, category)
Register to the context menu of the guild roster member mouse right click.

func: callback function to be called.
Signature:
Code:
local function func(rowData)
end
API 7.2
lib:RegisterFriendsListContextMenu(func, category)
Register to the context menu of the friends list mouse right click.

lib:RegisterGroupListContextMenu(func, category)
Register to the context menu of the group list mouse right click.

Both analog to RegisterGuildRosterContextMenu. See above.

Example
Lua Code:
  1. local function AddItem(data)
  2. AddCustomMenuItem("Example", function() d(data.displayName) end)
  3. end
  4.  
  5. local menu = LibCustomMenu
  6. menu:RegisterFriendsListContextMenu(AddItem, menu.CATEGORY_EARLY)
  7. menu:RegisterFriendsListContextMenu(AddItem, menu.CATEGORY_LAST)
version 7.2.1:
- Fixed nil error in AddCustomMenuItem. Sorry.

version 7.2.0:
- New functions RegisterFriendsListContextMenu and RegisterGroupListContextMenu as requested.

version 7.1.3:
- Update for "High Isle".

version 7.1.2:
- Fix for U32 adding a divider to header menu item. Thanks to @silvereyes.

version 7.1.1:
- Fixed issue with Shissu's Guild Tools. Thanks to @marcbf for reporting.

version 7.1.0:
- New API function RegisterGuildRosterContextMenu. Requested by @Saenic.

version 7.0.1:
- Allow to click sub-menu button itself. (a bit like a DropDown-Button)
- Allow to refresh/change other sub-menu items with clicking a checkbox menu item.

version 7.0.0:
- Removed LibStub support
- Added new menu item type: MENU_ADD_OPTION_HEADER

version 6.9.5:
- Update to API 100034 "Flames of Ambition".

version 6.9.4:
- Update to API 100033 "Markarth".

version 6.9.3:
- Update to API 100032 "Stonethorn".

version 6.9.2. Upon request added a new function RegisterPlayerContextMenu to added menu items to the player context menu of the chat.

version 6.9.1: Forgotten to increase the version number for LibStub legacy support. Added a warning, if LibStub has a "newer" version, which should not be!

version 6.9.0:
- Support keyboard modifier keys for inventory context menu to create special menus using those keys.

version 6.8.2:
- Update to API 100030 "Harrowstorm".

version 6.8.1:
- Update to API 100029 "Dragonhold".

version 6.8.0:
- Fix layout of built-in checkbox button of menu top level entries
- Added tooltip support: Either callback function or text string.

version 6.7.1:
- Update to API 100028 "Scalebreaker".

version 6.7.0:
- API bump 100027 "Elsweyr".
- Accessible via LibCustomMenu.
- Use of LibStub is optional.

version 6.6.3:
- Update to API 100026 "Wrathstone".

version 6.6.2:
- Reverted back to depend on LibStub. It is too early for that.

version 6.6.1:
- Update to API 100025 "Murkmire".
- Work without LibStub as well.

version 6.6:
- Update to API 100024 "Wolfhunter".
- New library load structure.

version 6.5: Fix for PTS.

version 6.4: Fixed compatibility with other addons hooking the context-menu. Like Craft Bag Extended.

version 6.3:
- Improve compabitility with AGS.

version 6.2:
- Handle inventory context menu and key strip menu. Take 2.


version 6.1:
- Fixed a conflict with CraftBagExtended.

version 6:
- Handle inventory context menu and key strip menu.


version 5:
- Supporting checkboxes in submenus.
- Fixed Divider menu item.

version 4.3:
- Update for "Horns of the Reach".

version 4.2.0:
- Fixed rare timing issue closing menu while mouse is over sub-menu.
- APIVersion update to 100017.

version 4.1.1:
- APIVersion update to 100014.

version 4.1:
- Added ZO_InventorySlotActions:AddCustomSlotAction. (Requested by merlight)
- APIVersion update to 100013.

version 4: * Working with Orsinium. Just the manifest APIVersion must be updated
- Fixed issue: main menu not closing if sub-menu used outside inventory. Thanks to circonian.

version 3:
- New menu item type: Divider. A static text "-" will be displayed as a divider. You can use <lib>.DIVIDER for better readability.

version 2:
- New global function AddCustomSubMenuItem

version 1:
- New global function AddCustomMenuItem as a replacement for AddMenuItem.
Optional Files (0)


Archived Files (35)
File Name
Version
Size
Uploader
Date
7.2.0
8kB
votan
03/11/23 11:59 AM
7.1.3
8kB
votan
04/24/22 09:04 AM
7.1.2
8kB
votan
10/24/21 07:44 AM
7.1.1
8kB
votan
09/05/21 07:30 AM
7.1.0
8kB
votan
09/04/21 09:32 AM
7.0.1
8kB
votan
07/04/21 04:46 AM
7.0.0
8kB
votan
04/28/21 11:21 AM
6.9.5
7kB
votan
02/20/21 09:09 AM
6.9.4
7kB
votan
11/02/20 04:41 AM
6.9.3
7kB
votan
08/22/20 04:55 AM
6.9.2
7kB
votan
04/21/20 03:12 PM
6.9.1
7kB
votan
04/04/20 06:22 AM
6.9.0
7kB
votan
04/03/20 11:43 AM
6.8.2
7kB
votan
02/15/20 11:44 AM
6.8.1
7kB
votan
10/03/19 04:37 AM
6.8.0
7kB
votan
08/07/19 01:15 PM
6.7.1
7kB
votan
07/30/19 11:57 AM
6.7.0
7kB
votan
05/18/19 08:07 AM
6.6.3
16kB
votan
02/23/19 10:15 AM
6.6.2
8kB
votan
10/21/18 09:31 AM
6.6.1
7kB
votan
10/19/18 12:13 PM
6.6
14kB
votan
08/13/18 11:17 AM
6.5
8kB
votan
04/22/18 05:21 AM
6.4
7kB
votan
04/16/18 11:45 AM
6.3
7kB
votan
03/03/18 10:58 AM
6.2
8kB
votan
02/02/18 12:35 AM
5
7kB
votan
01/27/18 03:11 PM
5
7kB
votan
08/15/17 12:34 PM
4.3
6kB
votan
07/15/17 01:00 PM
4.2.0
6kB
votan
10/12/16 12:56 PM
4.1.1
6kB
votan
03/07/16 12:13 PM
4.1.0
6kB
votan
11/22/15 02:24 PM
4.0.0
6kB
votan
08/06/15 10:48 AM
3.0.0
6kB
votan
07/25/15 05:36 AM
2.0.0
5kB
votan
07/11/15 10:51 AM


Post A Reply Comment Options
Unread 04/28/21, 11:30 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1663
Uploads: 40
Version 7.0.0 will break Dolgubon's Lazy Writ Crafter (up to 3.0.4), because the way it includes the library can no longer supported. Sorry.
You can change the DolgubonsLazyWritCreator.txt to include the library the supported way:
Code:
; This Add-on is not created by, affiliated with or sponsored by ZeniMax
; Media Inc. or its affiliates. The Elder Scrolls® and related logos are
; registered trademarks or trademarks of ZeniMax Media Inc. in the United
; States and/or other countries. All rights reserved.
; You can read the full terms at https://account.elderscrollsonline.com/add-on-terms

## Title: Dolgubon's Lazy Writ Creator v3.0.4
## APIVersion: 100034 100033
## Author: Dolgubon
## Version: 3.0.4
## DependsOn: LibAddonMenu-2.0 LibLazyCrafting LibCustomMenu
## OptionalDependsOn: LibAddonMenu-2.0 pChat LibLazyCrafting LibStub LibFeedback 
## SavedVariables: DolgubonsWritCrafterSavedVars

libs\LibCustomTitles\LibCustomTitles.lua

libs\LibFeedback\feedback.lua

#libs\LibCustomMenu\LibCustomMenu.lua

HelperFunctions.lua
LootHandler.lua
QuestHandler.lua

WritCreater.xml
WritCreater.lua
MasterWrits.lua
BankWithdraw.lua

Languages/default.lua
Languages/$(language).lua
SettingsMenu.lua
SlashCommands.lua
Tutorial.lua
ReticleChanges.lua
Crafter.lua
ResetWarning.lua
StatsWindow.lua
bindings.xml
Last edited by votan : 04/28/21 at 11:31 AM.
Report comment to moderator  
Reply With Quote
Unread 02/02/24, 02:33 PM  
woody4853

Forum posts: 0
File comments: 1
Uploads: 0
hey i am new to eso pc and kind of new to pc things in general. i love all the adds on and in the last few days my lazy writ crafter has stopped working and i keep getting error codes. i will paste them below. i have been reading some of the above comments, but sadly i dont understand pretty well anything. how can i fix them? and is there a page here somewhere to read and kind of understand what you all i do i find it very intresting and love to learn. thanks in adavance.

Failed to create control 'LibCustomMenuSubmenu'. Duplicate name.

stack traceback:
[C]: in function 'CreateControl'
user:/AddOns/DolgubonsLazySetCrafter/Libs/LibCustomMenu/LibCustomMenu.lua:85: in function 'Submenu:Initialize'
<Locals> self = [table:1]{}, name = "LibCustomMenuSubmenu" </Locals>
user:/AddOns/DolgubonsLazySetCrafter/Libs/LibCustomMenu/LibCustomMenu.lua:78: in function 'Submenu:New'
<Locals> self = [table:2]{__isAbstractClass = F}, object = [table:1] </Locals>
user:/AddOns/DolgubonsLazySetCrafter/Libs/LibCustomMenu/LibCustomMenu.lua:628: in function 'OnAddonLoaded'
<Locals> event = 65536, name = "LibDebugLogger" </Locals>

user:/AddOns/DolgubonsLazySetCrafter/Libs/LibCustomMenu/LibCustomMenu.lua:86: attempt to index a nil value
stack traceback:
user:/AddOns/DolgubonsLazySetCrafter/Libs/LibCustomMenu/LibCustomMenu.lua:86: in function 'Submenu:Initialize'
<Locals> self = [table:1]{}, name = "LibCustomMenuSubmenu" </Locals>
user:/AddOns/DolgubonsLazySetCrafter/Libs/LibCustomMenu/LibCustomMenu.lua:78: in function 'Submenu:New'
<Locals> self = [table:2]{__isAbstractClass = F}, object = [table:1] </Locals>
user:/AddOns/DolgubonsLazySetCrafter/Libs/LibCustomMenu/LibCustomMenu.lua:628: in function 'OnAddonLoaded'
<Locals> event = 65536, name = "LibDebugLogger" </Locals>

user:/AddOns/DolgubonsLazySetCrafter/SetCrafterUI.lua:358: function expected instead of nil
stack traceback:
user:/AddOns/DolgubonsLazySetCrafter/SetCrafterUI.lua:358: in function 'makeDropdownSelections'
<Locals> comboBoxContainer = ud, tableInfo = [table:1]{}, text = "Armour Trait", x = -160, y = 120, comboBoxLocation = 1, selectionTypes = "armourTrait", isArmourCombobox = T, comboBox = ud </Locals>
user:/AddOns/DolgubonsLazySetCrafter/SetCrafterUI.lua:451: in function 'DolgubonSetCrafter.setupComboBoxes'
<Locals> UIStrings = [table:2]{armourTrait = "Armour Trait", level = "Level", patternHeader = "Select Pieces", usesMimicStone = "This item will be made using a...", noSet = "No Set", mimicStones = "Use Mimic Stones", CP = "CP", chatRequirements = "Requirements to Chat", addToQueue = "Add to Queue", comboboxDefault = "Unselected", genericTrait = "Trait", notEnoughSpecificMat = "You do not have enough of this...", materialScrollTitle = "Material Requirements", weaponTrait = "Weapon Trait", resetToDefault = "Clear Selections", quality = "Quality", mailRequirements = "Mail Requirements", craftStart = "Start Crafting", defaultUserId = "Enter @UserId", queueHeader = "Crafting Queue", autoCraft = "Auto Craft", comboboxHeader = "Attributes", style = "Style", gearSet = "Set", selectPrompt = "Please select a <<1>>", jewelryTrait = "Jewelry Trait", pattern = "Piece", invalidLevel = "Invalid Level", notEnoughMats = "You do not have enough materia...", notEnoughKnowledge = "You do not have enough knowled...", clearQueue = "Clear Queue", multiplier = "Multiplier"} </Locals>
user:/AddOns/DolgubonsLazySetCrafter/SetCrafterUI.lua:966: in function 'DolgubonSetCrafter.initializeFunctions.setupUI'
user:/AddOns/DolgubonsLazySetCrafter/SetCrafter.lua:108: in function 'DolgubonSetCrafter:Initialize'
<Locals> self = [table:3]{version = 5, name = "DolgubonsLazySetCrafter", lang = "en"} </Locals>
user:/AddOns/DolgubonsLazySetCrafter/SetCrafter.lua:129: in function 'DolgubonSetCrafter.OnAddOnLoaded'
<Locals> event = 65536, addonName = "DolgubonsLazySetCrafter" </Locals>
Report comment to moderator  
Reply With Quote
Unread 01/01/24, 01:35 PM  
heinrich6745

Forum posts: 0
File comments: 17
Uploads: 0
Failed to create control 'LibCustomMenuSubmenu'. Duplicate name.

stack traceback:
[C]: in function 'CreateControl'
user:/AddOns/GoHome/Libs/LibCustomMenu/LibCustomMenu.lua:85: in function 'Submenu:Initialize'
<Locals> self = [table:1]{}, name = "LibCustomMenuSubmenu" </Locals>
user:/AddOns/GoHome/Libs/LibCustomMenu/LibCustomMenu.lua:78: in function 'Submenu:New'
<Locals> self = [table:2]{__isAbstractClass = F}, object = [table:1] </Locals>
user:/AddOns/GoHome/Libs/LibCustomMenu/LibCustomMenu.lua:648: in function 'OnAddonLoaded'
<Locals> event = 65536, name = "LibCustomMenu" </Locals>
user:/AddOns/GoHome/Libs/LibCustomMenu/LibCustomMenu.lua:86: attempt to index a nil value
stack traceback:
user:/AddOns/GoHome/Libs/LibCustomMenu/LibCustomMenu.lua:86: in function 'Submenu:Initialize'
<Locals> self = [table:1]{}, name = "LibCustomMenuSubmenu" </Locals>
user:/AddOns/GoHome/Libs/LibCustomMenu/LibCustomMenu.lua:78: in function 'Submenu:New'
<Locals> self = [table:2]{__isAbstractClass = F}, object = [table:1] </Locals>
user:/AddOns/GoHome/Libs/LibCustomMenu/LibCustomMenu.lua:648: in function 'OnAddonLoaded'
<Locals> event = 65536, name = "LibCustomMenu" </Locals>
Last edited by heinrich6745 : 01/01/24 at 01:35 PM.
Report comment to moderator  
Reply With Quote
Unread 11/03/23, 08:07 AM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 4881
File comments: 5947
Uploads: 78
Hi Votan,

if you use checkboxes in a menu the menu height is calculated wrong somehow. The more checkboxes, the heigher the menu frame:

Happens without the header entry too:

And without the divider:



I'll see if I can find the reason and update you with a fix if easily doable.

Edit:
I've added some code to your already exisitng function cleanupDivider -> renamed to cleanupEntryHeights

Lua Code:
  1. --Calculate shown headers, divider, checkboxes and remove their special height from
  2. --the total menu height
  3. --Calculate shown headers, divider, checkboxes and remove their special height from
  4. --the total menu height
  5. local function cleanupEntryHeights(items)
  6. LibCustomMenu._debugItems = ZO_ShallowTableCopy(items)
  7.  
  8.     local wasDivider = true
  9.     local height = 0
  10.     for i = #items, 1, -1 do
  11.         local menuEntry = items[i]
  12.         local item = menuEntry.item
  13.         local isDivider = menuEntry.isDivider
  14.         local isHeader = menuEntry.isHeader
  15.         local isCheckbox = menuEntry.checkbox
  16.         if isDivider then
  17.             if wasDivider or i == 1 then
  18.                 height = height + item.storedHeight
  19.                 menuEntry.item.storedHeight = 0
  20.                 item:SetHidden(true)
  21.             else
  22.                 item:SetHidden(false)
  23.             end
  24.             wasDivider = isDivider
  25.             isDivider = true
  26.         else
  27.             wasDivider = false
  28.             if isCheckbox then
  29.                 local storedHeightOfItem = item.storedHeight
  30.                 local heightOfItem = item:GetHeight()
  31.                 local heightToCompare = ((storedHeightOfItem ~= heightOfItem) and storedHeightOfItem) or heightOfItem
  32.                 local heightOfCheckbox = menuEntry.checkbox:GetHeight()
  33.                 local checkboxHeightDiff = zo_clamp(heightToCompare - heightOfCheckbox, 0, heightToCompare)
  34.                 height = height + checkboxHeightDiff
  35.             end
  36.         end
  37.     end
  38.     return height
  39. end
  40.  
  41. local function HookShowMenu()
  42.     local orgShowMenu = ShowMenu
  43.     function ShowMenu(...)
  44.         ZO_Menu.height = ZO_Menu.height - cleanupEntryHeights(ZO_Menu.items)
  45.         return orgShowMenu(...)
  46.     end
  47. end

Now the entries look like this:

-> Main ZO_Menu height is missing a few pixels at the bottom. The selection highlight is above the bottom border...





Maybe this is related to a ZOs bug too. Submenus look good but at the main menu ZO_Menu the checkbox entries are kinda wrong height?
The row selection highlight e.g. is to high for them:

The highlight is above the next entry below, no matter if it's another checkbox, a divider, or the bottom line of the ZO_Menu background



Edit2
The rows highlight missplacement seems to origin from function
AddCustomMenuItem
Code:
local lastAdded = ZO_Menu.items[index]
	if itemType == MENU_ADD_OPTION_CHECKBOX then
		lastAdded.item:SetAnchor(TOPLEFT, lastAdded.checkbox, TOPLEFT, 0, -2) --Change to -4, see comment below!
	end
Here the -2 (y) at the SetAnchor is moving the text of the label a bit more to the top, but the highlight anchors to this label and actually a -4 would be needed. But this again miss places the text relatively to the checkbox control left of it, a bit.
See below:






I've also fixed the error at the clickable header -> checkbox "On/Off" is shown, see my post: #170368

Code of my changed LibAddonMenu-lua file:
https://www.dropbox.com/scl/fi/3hbabuelcqaskjftavu42/LibCustomMenu.lua?rlkey=aorib4owufbs6qfm49wyw8dng&dl=1
Last edited by Baertram : 11/03/23 at 09:53 AM.
Report comment to moderator  
Reply With Quote
Unread 04/17/23, 03:06 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1663
Uploads: 40
Originally Posted by Baertram
Hey votan,

the header lines are using the virtual template "ZO_AddOnSectionHeaderRow" in their HeaderFactory function.
But this xml template uses an ON/OFF checkbox since some patches and if you click the header rows in LibCustomMenu menus it shows an AN/AUS or ON/OFF all of sudden next to the text

Here is a fix, in the function SetupHeader determine the Checkbox child and set it hidden + MouseEnabled(false):

Lua Code:
  1. local function SetupHeader(pool, control)
  2.     local label = control:GetNamedChild("Text")
  3.     local divider = control:GetNamedChild("Divider")
  4.     local checkbox = control:GetNamedChild("Checkbox")
  5.     local orgGetTextDimensions = label.GetTextDimensions
  6.     function label:GetTextDimensions()
  7.         local w, h = orgGetTextDimensions(self)
  8.         local hdivider = divider and (select(2, divider:GetDimensions()) + 9) or 0
  9.         return w, h + hdivider
  10.     end
  11.  
  12.     if checkbox then
  13.         checkbox:SetHidden(true)
  14.         checkbox:SetMouseEnabled(false)
  15.     end
  16.  
  17.     label:ClearAnchors()
  18.     label:SetAnchor(TOPLEFT, control, TOPLEFT, 0, 3)
  19.     label:SetAnchor(TOPRIGHT, control, TOPRIGHT, 0, 3)
  20.     label:SetMaxLineCount(1)
  21.  
  22.     label:SetHidden(false)
  23.     control.nameLabel = label
  24.  
  25.     control.isHeader = true
  26.     control.item = control
  27.     control:SetMouseEnabled(false)
  28.  
  29.     if divider then
  30.         divider:ClearAnchors()
  31.         divider:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 3)
  32.         divider:SetAnchor(RIGHT, control, RIGHT, 0, 0, ANCHOR_CONSTRAINS_X)
  33.     end
  34. end
Oh really Ok. Thanks for letting me know.
Report comment to moderator  
Reply With Quote
Unread 04/16/23, 07:53 PM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 4881
File comments: 5947
Uploads: 78
Hey votan,

the header lines are using the virtual template "ZO_AddOnSectionHeaderRow" in their HeaderFactory function.
But this xml template uses an ON/OFF checkbox since some patches and if you click the header rows in LibCustomMenu menus it shows an AN/AUS or ON/OFF all of sudden next to the text

Here is a fix, in the function SetupHeader determine the Checkbox child and set it hidden + MouseEnabled(false):

Lua Code:
  1. local function SetupHeader(pool, control)
  2.     local label = control:GetNamedChild("Text")
  3.     local divider = control:GetNamedChild("Divider")
  4.     local checkbox = control:GetNamedChild("Checkbox")
  5.     local orgGetTextDimensions = label.GetTextDimensions
  6.     function label:GetTextDimensions()
  7.         local w, h = orgGetTextDimensions(self)
  8.         local hdivider = divider and (select(2, divider:GetDimensions()) + 9) or 0
  9.         return w, h + hdivider
  10.     end
  11.  
  12.     if checkbox then
  13.         checkbox:SetHidden(true)
  14.         checkbox:SetMouseEnabled(false)
  15.     end
  16.  
  17.     label:ClearAnchors()
  18.     label:SetAnchor(TOPLEFT, control, TOPLEFT, 0, 3)
  19.     label:SetAnchor(TOPRIGHT, control, TOPRIGHT, 0, 3)
  20.     label:SetMaxLineCount(1)
  21.  
  22.     label:SetHidden(false)
  23.     control.nameLabel = label
  24.  
  25.     control.isHeader = true
  26.     control.item = control
  27.     control:SetMouseEnabled(false)
  28.  
  29.     if divider then
  30.         divider:ClearAnchors()
  31.         divider:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 3)
  32.         divider:SetAnchor(RIGHT, control, RIGHT, 0, 0, ANCHOR_CONSTRAINS_X)
  33.     end
  34. end
Report comment to moderator  
Reply With Quote
Unread 03/30/23, 02:10 PM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1663
Uploads: 40
Originally Posted by sinnereso
Im having a strange issue with my context menu that saves a players @name. I thought It was my fault but I can find nothing wrong and does fix itself if I open the addon settings for it which is extra wierd. After exhausting all my options i started peeking around in libaddonmenu and libcustommenu notes and found your most recent patch apparently adresses the issue that I've just noticed has just started for me. Based on what I can see I might guess the setting panel description field somehow doesn't exist yet to be edited until you open the addon settings. I realize thats likely a me or libaddonmenu issue but throwing it out there incase anything comes to mind.

ERRORS:
Code:
user:/AddOns/MyAddon/MyAddon.lua:249: attempt to index a nil value
stack traceback:
user:/AddOns/MyAddon/MyAddon.lua:249: in function 'MyAddon.SavePlayer'
|caaaaaa<Locals> displayName = "@someone" </Locals>|r
user:/AddOns/MyAddon/MyAddon.lua:242: in function 'OnSelect'
/EsoUI/Libraries/ZO_ContextMenus/ZO_ContextMenus.lua:476: in function 'ZO_Menu_ClickItem'
|caaaaaa<Locals> control = ud, button = 1, menuEntry = [table:1]{itemYPad = 0, isDivider = F} </Locals>|r
user:/AddOns/LibCustomMenu/LibCustomMenu.lua:604: in function 'MouseUp'
I'm curious if its related to your fixes as I cant find anything wrong, related or even changed on my end to cause this issue.

initializing the menu stuff with this ON_LOADED:
Code:
local category = LibCustomMenu.CATEGORY_LATE--<<< context menu stuff
LibCustomMenu:RegisterGuildRosterContextMenu(MyAddon.AddGGFContext, category)
LibCustomMenu:RegisterFriendsListContextMenu(MyAddon.AddGGFContext, category)
LibCustomMenu:RegisterGroupListContextMenu(MyAddon.AddGGFContext, category)
then my 2 functions that save the player from the context menu, display it in chat and then update the addon settings panel field to display it. This is where the issue is. its saving the saved variable and displaying the correct @NAME in chat but getting nil error on the settings panel fueld update which hasnt changed.
Code:
function MyAddon.AddGGFContext(data)
	AddCustomMenuItem("Save to MyAddon", function() MyAddon.SavePlayer(data.displayName) end)
	return
end

function MyAddon.SavePlayer(displayName)
	MyAddon.savedVariables.savedPlayer = displayName
	df("|c6666FF[MyAddon]|r Saving: " .. tostring(displayName))
	MyAddon_SETTINGS_SAVEDPLAYER_TEXT.data.text = "Saved Player: " .. tostring(displayName)-- errors on this line 249
	MyAddon_SETTINGS_SAVEDPLAYER_TEXT:UpdateValue()
	return
end
This may be a libaddonmenu issue but your recent update sounds related so I thought I would ask.
What is in your line 249.
Report comment to moderator  
Reply With Quote
Unread 03/26/23, 07:18 PM  
sinnereso
AddOn Author - Click to view AddOns

Forum posts: 243
File comments: 59
Uploads: 4
Im having a strange issue with my context menu that saves a players @name. I thought It was my fault but I can find nothing wrong and does fix itself if I open the addon settings for it which is extra wierd. After exhausting all my options i started peeking around in libaddonmenu and libcustommenu notes and found your most recent patch apparently adresses the issue that I've just noticed has just started for me. Based on what I can see I might guess the setting panel description field somehow doesn't exist yet to be edited until you open the addon settings. I realize thats likely a me or libaddonmenu issue but throwing it out there incase anything comes to mind.

ERRORS:
Code:
user:/AddOns/MyAddon/MyAddon.lua:249: attempt to index a nil value
stack traceback:
user:/AddOns/MyAddon/MyAddon.lua:249: in function 'MyAddon.SavePlayer'
|caaaaaa<Locals> displayName = "@someone" </Locals>|r
user:/AddOns/MyAddon/MyAddon.lua:242: in function 'OnSelect'
/EsoUI/Libraries/ZO_ContextMenus/ZO_ContextMenus.lua:476: in function 'ZO_Menu_ClickItem'
|caaaaaa<Locals> control = ud, button = 1, menuEntry = [table:1]{itemYPad = 0, isDivider = F} </Locals>|r
user:/AddOns/LibCustomMenu/LibCustomMenu.lua:604: in function 'MouseUp'
I'm curious if its related to your fixes as I cant find anything wrong, related or even changed on my end to cause this issue.

initializing the menu stuff with this ON_LOADED:
Code:
local category = LibCustomMenu.CATEGORY_LATE--<<< context menu stuff
LibCustomMenu:RegisterGuildRosterContextMenu(MyAddon.AddGGFContext, category)
LibCustomMenu:RegisterFriendsListContextMenu(MyAddon.AddGGFContext, category)
LibCustomMenu:RegisterGroupListContextMenu(MyAddon.AddGGFContext, category)
then my 2 functions that save the player from the context menu, display it in chat and then update the addon settings panel field to display it. This is where the issue is. its saving the saved variable and displaying the correct @NAME in chat but getting nil error on the settings panel fueld update which hasnt changed.
Code:
function MyAddon.AddGGFContext(data)
	AddCustomMenuItem("Save to MyAddon", function() MyAddon.SavePlayer(data.displayName) end)
	return
end

function MyAddon.SavePlayer(displayName)
	MyAddon.savedVariables.savedPlayer = displayName
	df("|c6666FF[MyAddon]|r Saving: " .. tostring(displayName))
	MyAddon_SETTINGS_SAVEDPLAYER_TEXT.data.text = "Saved Player: " .. tostring(displayName)-- errors on this line 249
	MyAddon_SETTINGS_SAVEDPLAYER_TEXT:UpdateValue()
	return
end
This may be a libaddonmenu issue but your recent update sounds related so I thought I would ask.
Last edited by sinnereso : 03/26/23 at 08:26 PM.
Report comment to moderator  
Reply With Quote
Unread 03/13/23, 03:42 PM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1663
Uploads: 40
Re: Error after U37

Originally Posted by Tiara Ra
Lua Error: user:/AddOns/LibCustomMenu/LibCustomMenu.lua:729: attempt to index a nil value
stack traceback:
user:/AddOns/LibCustomMenu/LibCustomMenu.lua:729: in function 'AddCustomMenuItem'
<Locals> mytext = "-", orgItemPool = [table:1]{m_NextControlId = 30, m_NextFree = 31}, orgCheckboxItemPool = [table:2]{m_NextControlId = 30, m_NextFree = 31}, isDivider = T </Locals>
user:/AddOns/Postmaster/classes/SendMailField.lua:101: in function 'class.SendMailField:OnControlMouseUp'
<Locals> self = [table:3]{settingsKeyValues = "sendmailRecipients", name = "PostmasterSendMailField", settingsKeyEnabled = "sendmailSaveRecipients", contextMenuLabel = "Recent Contacts"}, control = ud, mouseButton = 2, upInside = T, altKey = F, shiftKey = F, ctrlKey = F, commandKey = F, savedValues = [table:4]{}, removeEntries = [table:5]{} </Locals>
(tail call): ?|r
Yep. Sorry. Fixed.
There is ZOS internal check, which make the second parameter mandantory. That did not work with dividers. Failed to test that.
Report comment to moderator  
Reply With Quote
Unread 03/13/23, 07:43 AM  
Tiara Ra
 
Tiara Ra's Avatar

Forum posts: 4
File comments: 278
Uploads: 0
Error after U37

Lua Error: user:/AddOns/LibCustomMenu/LibCustomMenu.lua:729: attempt to index a nil value
stack traceback:
user:/AddOns/LibCustomMenu/LibCustomMenu.lua:729: in function 'AddCustomMenuItem'
<Locals> mytext = "-", orgItemPool = [table:1]{m_NextControlId = 30, m_NextFree = 31}, orgCheckboxItemPool = [table:2]{m_NextControlId = 30, m_NextFree = 31}, isDivider = T </Locals>
user:/AddOns/Postmaster/classes/SendMailField.lua:101: in function 'class.SendMailField:OnControlMouseUp'
<Locals> self = [table:3]{settingsKeyValues = "sendmailRecipients", name = "PostmasterSendMailField", settingsKeyEnabled = "sendmailSaveRecipients", contextMenuLabel = "Recent Contacts"}, control = ud, mouseButton = 2, upInside = T, altKey = F, shiftKey = F, ctrlKey = F, commandKey = F, savedValues = [table:4]{}, removeEntries = [table:5]{} </Locals>
(tail call): ?|r
Last edited by Tiara Ra : 03/13/23 at 07:45 AM.
Report comment to moderator  
Reply With Quote
Unread 03/11/23, 02:34 PM  
sinnereso
AddOn Author - Click to view AddOns

Forum posts: 243
File comments: 59
Uploads: 4
Re: Re: any plans for friends list and group support?

Originally Posted by votan
Originally Posted by sinnereso
Have any plans for:

RegisterFriendRosterContextMenu

and

RegisterGroupRosterContextMenu

by chance?
Yes, if you need that, I can do that.

/Edit: Done with version 7.2.0.
OMG THANKYOU!!! they are all instantly working and ive been going crazy over these for 2 days.. well guild group and friends working to perfection... chat contect menu im still working on with the (playerName, rawData) as I need to get that converted to an @name or be able to... Currently it is working if the user has the USER ID preference set.. If they have it set to character name then it gets messy cuz its trying to save that and I cant find a way YET to convert that to @NAME. but otherwise thank you soo much this is awesome.
Report comment to moderator  
Reply With Quote
Unread 03/11/23, 01:42 PM  
sinnereso
AddOn Author - Click to view AddOns

Forum posts: 243
File comments: 59
Uploads: 4
Re: Re: any plans for friends list and group support?

Originally Posted by votan
Originally Posted by sinnereso
Have any plans for:

RegisterFriendRosterContextMenu

and

RegisterGroupRosterContextMenu

by chance?
Yes, if you need that, I can do that.

/Edit: Done with version 7.2.0.
Damn your prostar!! Would you happen to have a list of data or variables retrieved by the registerguildroster one? like in the rowData? ive been poking around with zgoo but nothing showing up i can see related. I'm trying to convert the name of the player in guild that was clicking into an @NAME for use elsewhere withint my addon.

*edit infact all the accessible variables from all of them would be handy to see in the addon info page
Last edited by sinnereso : 03/11/23 at 01:44 PM.
Report comment to moderator  
Reply With Quote
Unread 03/11/23, 11:36 AM  
sinnereso
AddOn Author - Click to view AddOns

Forum posts: 243
File comments: 59
Uploads: 4
Re: Re: any plans for friends list and group support?

Originally Posted by votan
Originally Posted by sinnereso
Have any plans for:

RegisterFriendRosterContextMenu

and

RegisterGroupRosterContextMenu

by chance?
Yes, if you need that, I can do that.
OMG I would love that. To be honest i was a little surprised it wasnt already in it so I looked through it like crazy trying to figure out howto use it. I've had a hard time with setting up my context menus and it has helped I think once I got the hang of it.

I'm trying to add context menus in guild friends group and chat to basically save a users @NAME to a variable for use within the addon. So if its possible a similar setup to guild or chat be nice like this:


lib:RegisterPlayerContextMenu(func, category)

local function func(playerName, rawName)
end

I do understand the different data formats everything uses though so whatever will do. Its a hot mess trying to get everything into @NAME for my use =p
Last edited by sinnereso : 03/11/23 at 11:59 AM.
Report comment to moderator  
Reply With Quote
Unread 03/11/23, 09:06 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1663
Uploads: 40
Re: any plans for friends list and group support?

Originally Posted by sinnereso
Have any plans for:

RegisterFriendRosterContextMenu

and

RegisterGroupRosterContextMenu

by chance?
Yes, if you need that, I can do that.

/Edit: Done with version 7.2.0.
Last edited by votan : 03/11/23 at 12:00 PM.
Report comment to moderator  
Reply With Quote
Unread 03/11/23, 06:45 AM  
sinnereso
AddOn Author - Click to view AddOns

Forum posts: 243
File comments: 59
Uploads: 4
Question any plans for friends list and group support?

Have any plans for:

RegisterFriendRosterContextMenu

and

RegisterGroupRosterContextMenu

by chance?
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: