Download
(11 Kb)
Download
Updated: 07/12/24 12:08 PM
Pictures
File Info
Compatibility:
Update 43 (10.1.0)
Gold Road (10.0.0)
Scions of Ithelia (9.3.0)
Endless Archive (9.2.5)
base-game patch (9.1.5)
Necrom (9.0.0)
Scribes of Fate (8.3.5)
Updated:07/12/24 12:08 PM
Created:05/16/21 12:49 PM
Monthly downloads:796
Total downloads:10,806
Favorites:31
MD5:
10.0.0
Take One  Updated less than 3 days ago!  Popular! (More than 5000 hits)
Version: 1.2.0
by: mightyjo [More]
Take One
Author: Mightyjo

Depends on:
- LibAddonMenu-2.0
- LibCustomMenu
- LibDebugLogger

Optionally depends on:
- DebugLogViewer

This add-on provides a context menu option to pull one item from a Bank or Guild Bank stack into your inventory.
NEW in v1.2.0! This add-on provides a context menu option to pull all but one item from a Bank or Guild Bank stack into your inventory.

The context menu item will only appear when all the preconditions to use it are met
- The source slot is in your Bank or Guild Bank.
- You have permission to withdraw and deposit into the Guild Bank.
- You have 2 free backpack slots (for Guild Bank withdrawals).
- The source stack contains more than 1 item.

Requires 2 free slots in your backpack
When working with the Guild Bank it really just automates the process of withdrawing the whole stack in a bank slot, splitting out one item from the stack, and returning the remaining stack to the Guild Bank. Consequently, you must have 2 free slots in your backpack to withdraw 1 item from a Guild Bank stack. Annoying, but that's what the API allows.

Settings
You can turn on debug logging if you're having a problem. If you have DebugLogViewer installed you'll be able to see the add-on working in a UI window. Otherwise, the log is stored in your saved variables by LibDebugLogger whenever you quit or /reloadui.

Support
If you need help, find a bug, or have a translation post here. You can also open an issue or pull request on the GitHub: https://github.com/Mightyjo/TakeOne/issues.


Thanks
Many thanks to the authors whose examples I followed:
- @Marify
- Valandil
- @Architectura
- @Magnum1997
- Wobin
- CrazyDutchGuy
- Ayantir
- silvereyes
- Baertram

License



This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Archived Files (10)
File Name
Version
Size
Uploader
Date
1.1.6
10kB
mightyjo
10/30/23 09:25 PM
1.1.5
10kB
mightyjo
04/14/23 06:52 PM
1.1.4
10kB
mightyjo
06/06/22 09:02 PM
1.1.3
10kB
mightyjo
03/18/22 05:59 PM
1.1.2
10kB
mightyjo
08/23/21 08:01 PM
1.1.1
10kB
mightyjo
05/26/21 12:13 AM
1.1.0
10kB
mightyjo
05/25/21 11:02 PM
1.0.2
9kB
mightyjo
05/21/21 06:14 PM
1.0.1
9kB
mightyjo
05/20/21 09:57 PM
1.0.0
9kB
05/16/21 12:49 PM


Post A Reply Comment Options
Unread Yesterday, 12:34 PM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 5097
File comments: 6180
Uploads: 78
I had a look at my FCOIS code and actually I do not hook ShowMenu etc.
AddCustomSubMenuItem does not return the index as it seems.

So I'm using contMenuVars.contextMenuIndex = AddCustomMenuItem(...) and in that normal non submenu item I have the normal callback function.

And after the ShowMenu() call of my addon I check if the entry with index contMenuVars.contextMenuIndex exists
and manipulate it to disable the mouse if it's just a header entyr without function (not your usecase, just as an example)
and with a hook to
ZO_Menu_OnHide
I can change that SetMouseEnabled(true) again

So actually I did not manipulate a submenu entry to run a callback as the callback (looking at LCM code) opens the submenu!
What you could do though is SecurePostHook AddMenuItem function and find out if the data passed in is the one of your submenu entry (as LCM uses that too to add the submenu opener entries) and then use ZO_Menu.currentIndex to get the index of the submenu entry.

That way you can manipulate ZO_Menu.items[ZO_Menu.currentIndex] to use ZO_PreHookHandler(ZO_Menu.items[ZO_Menu.currentIndex].item, "OnClick", function(ctrl) runYourCallbackFunction now and return true to hopefully supress the original submenu opening callback OnClick function)
Or you need to replace the OnCliCk handler in total and set it nil again at ZO_Menu_OnHide


Originally Posted by mightyjo
Originally Posted by Baertram
LCM is just using ZO_Menu functions so you must do 2 things:
1st is to get the index off the entry that got the submenu (ZO_Menu.items[index]) which LCm should return by AddCustomSubmenuItem, I think.
2nd you need to hook into ZO_Menu code (not sure where it was but something like ShowMenu maybe or any other ZO_Menu func that is called within ShowMenu) and then add the callback to that ZO_Menu.items[indexOfSubmenu] properly so you can click it too.
Else it only opens the submenu.

Yeah I would love to see that directly in LCM API call to AddCustomSubMenuItem too, and had asked Votan for that but never got a feedback ;-)
Thanks for this! I'll ping when I get something working.

Originally Posted by Baertram
Oh remember that ShowMenu get's called from ZOs code AND each addon! So multiple times.
Good to know. I'll curry a unique cookie into it or something for an isValid function to check.

Originally Posted by Baertram
And in ClearMenu you need to PreHook and remove the callback at the ZO_Menu.items[submenuIndex] again else it will stay there for next menu as the controls are used from a pool and are reused!
Ah, I wondered why that pattern was emphasized. Thanks!
Report comment to moderator  
Reply With Quote
Unread Yesterday, 09:18 AM  
mightyjo
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 22
Uploads: 2
Originally Posted by Baertram
LCM is just using ZO_Menu functions so you must do 2 things:
1st is to get the index off the entry that got the submenu (ZO_Menu.items[index]) which LCm should return by AddCustomSubmenuItem, I think.
2nd you need to hook into ZO_Menu code (not sure where it was but something like ShowMenu maybe or any other ZO_Menu func that is called within ShowMenu) and then add the callback to that ZO_Menu.items[indexOfSubmenu] properly so you can click it too.
Else it only opens the submenu.

Yeah I would love to see that directly in LCM API call to AddCustomSubMenuItem too, and had asked Votan for that but never got a feedback ;-)
Thanks for this! I'll ping when I get something working.

Originally Posted by Baertram
Oh remember that ShowMenu get's called from ZOs code AND each addon! So multiple times.
Good to know. I'll curry a unique cookie into it or something for an isValid function to check.

Originally Posted by Baertram
And in ClearMenu you need to PreHook and remove the callback at the ZO_Menu.items[submenuIndex] again else it will stay there for next menu as the controls are used from a pool and are reused!
Ah, I wondered why that pattern was emphasized. Thanks!
Report comment to moderator  
Reply With Quote
Unread Yesterday, 08:44 AM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 5097
File comments: 6180
Uploads: 78
LCM is just using ZO_Menu functions so you must do 2 things:
1st is to get the index off the entry that got the submenu (ZO_Menu.items[index]) which LCm should return by AddCustomSubmenuItem, I think.
2nd you need to hook into ZO_Menu code (not sure where it was but something like ShowMenu maybe or any other ZO_Menu func that is called within ShowMenu) and then add the callback to that ZO_Menu.items[indexOfSubmenu] properly so you can click it too.
Else it only opens the submenu.

Yeah I would love to see that directly in LCM API call to AddCustomSubMenuItem too, and had asked Votan for that but never got a feedback ;-)

Oh remember that ShowMenu get's called from ZOs code AND each addon! So multiple times.
And in ClearMenu you need to PreHook and remove the callback at the ZO_Menu.items[submenuIndex] again else it will stay there for next menu as the controls are used from a pool and are reused!

Originally Posted by mightyjo
Originally Posted by Baertram
No I meant make it work in normal inventory, as mail and others like bank deposit and guild bank or house bank deposit use the same inventory fragment there it should work for all then.
So I can split the item stack in my inv (at mail panel e.g.) and theen "manually" attach the 1 split item.
No need to auto attach 1 item (unless this works fine, go ahead and add it, sure.
Oh! Yeah, a 'Split 1' action within your own backpack would be simple enough.

Originally Posted by Baertram
Should be easily doable, spy the code of my addon "DoItAll" it got a mail "Attach" routines and calls the ZOs API functions to try to attach items to a mail. Same should work for "Deposit" to bank, code is in there too).
Neat! I'll give DoItAll a look. The attachment API does look similar to the Guild banks. I just didn't grok how to find the target attachment slot. Looks like the LibCustomMenu API has advanced quite a bit. I suspect RegisterContextMenu from API 6.2 will help.


Originally Posted by Baertram
Not sure if I understand what you mean?
I just meant 1 submenu e.g. named like your addon name
and below that show all possible actions like
"Take / Deposit / Attach 1"
"Leave 1"
Yep, I got that. As a UX principle, I limit myself to two context menu spots. I like to keep my primary function visible and put everything else in the second spot. If I have two or more other functions, they go in a submenu. If just one, it takes the second spot. I'm about to reach three functions, so a submenu is forthcoming.

To improve users' target acquisition/click flow, I don't want to put the primary function behind a submenu. If I could get a single target to open the menu on mouseOver and still run a callback on mouseClick I'd love to use just one context menu item.

Originally Posted by Baertram
And you asked if there is a way to show a submenu and if you click the submenu opening line it would do something (call a callback function)?
That would be possible yes, but only with hacking into ZO_Menu code I'm doing this in FCOItemSaver e.g. to click teh FCOIS submenu opening line and open the LAM settings menu that way / or remove all marker icons.
But that's tricky to do and should not be used for your addon I guess.

One day when I make LibScrollableMenu work with Invenory context menus we will have the possibility to do so more easily! But that's future work
Yeah, I thought I'd seen this in one of your add-ons. Too bad it's so involved. It really feels like this should be possible with LibCustomMenu. I may fiddle with that and submit a PR if I find a solution. In the meantime, I'll make my second context menu item a submenu.
Report comment to moderator  
Reply With Quote
Unread Yesterday, 08:33 AM  
mightyjo
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 22
Uploads: 2
Originally Posted by Baertram
No I meant make it work in normal inventory, as mail and others like bank deposit and guild bank or house bank deposit use the same inventory fragment there it should work for all then.
So I can split the item stack in my inv (at mail panel e.g.) and theen "manually" attach the 1 split item.
No need to auto attach 1 item (unless this works fine, go ahead and add it, sure.
Oh! Yeah, a 'Split 1' action within your own backpack would be simple enough.

Originally Posted by Baertram
Should be easily doable, spy the code of my addon "DoItAll" it got a mail "Attach" routines and calls the ZOs API functions to try to attach items to a mail. Same should work for "Deposit" to bank, code is in there too).
Neat! I'll give DoItAll a look. The attachment API does look similar to the Guild banks. I just didn't grok how to find the target attachment slot. Looks like the LibCustomMenu API has advanced quite a bit. I suspect RegisterContextMenu from API 6.2 will help.


Originally Posted by Baertram
Not sure if I understand what you mean?
I just meant 1 submenu e.g. named like your addon name
and below that show all possible actions like
"Take / Deposit / Attach 1"
"Leave 1"
Yep, I got that. As a UX principle, I limit myself to two context menu spots. I like to keep my primary function visible and put everything else in the second spot. If I have two or more other functions, they go in a submenu. If just one, it takes the second spot. I'm about to reach three functions, so a submenu is forthcoming.

To improve users' target acquisition/click flow, I don't want to put the primary function behind a submenu. If I could get a single target to open the menu on mouseOver and still run a callback on mouseClick I'd love to use just one context menu item.

Originally Posted by Baertram
And you asked if there is a way to show a submenu and if you click the submenu opening line it would do something (call a callback function)?
That would be possible yes, but only with hacking into ZO_Menu code I'm doing this in FCOItemSaver e.g. to click teh FCOIS submenu opening line and open the LAM settings menu that way / or remove all marker icons.
But that's tricky to do and should not be used for your addon I guess.

One day when I make LibScrollableMenu work with Invenory context menus we will have the possibility to do so more easily! But that's future work
Yeah, I thought I'd seen this in one of your add-ons. Too bad it's so involved. It really feels like this should be possible with LibCustomMenu. I may fiddle with that and submit a PR if I find a solution. In the meantime, I'll make my second context menu item a submenu.
Report comment to moderator  
Reply With Quote
Unread Yesterday, 06:03 AM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 5097
File comments: 6180
Uploads: 78
Originally Posted by mightyjo
Originally Posted by Baertram
I think it does but just asking in case it does not (yet): Does your addon support CraftBag stack's "Take 1" and "All but 1" too?
And does it support the "Take 1" and "All but 1" at the normal inventory too?
I hadn't thought to try this. I think the craft bag uses the same API for item movement to & from the backpack so it should work. I'll check.

Originally Posted by Baertram
I often have the problem that I got a stack of items in my inv and only want to kepp 1 or only take 1 to send by mail to friends etc.
Would be such a timesaver if that works in normal inv too.
Mail attachments use a different set of APIs, but this might be possible. There's very little documentation on them so it won't happen quickly (unless it does).
No I meant make it work in normal inventory, as mail and others like bank deposit and guild bank or house bank deposit use the same inventory fragment there it should work for all then.
So I can split the item stack in my inv (at mail panel e.g.) and theen "manually" attach the 1 split item.
No need to auto attach 1 item (unless this works fine, go ahead and add it, sure. Should be easily doable, spy the code of my addon "DoItAll" it got a mail "Attach" routines and calls the ZOs API functions to try to attach items to a mail. Same should work for "Deposit" to bank, code is in there too).

Originally Posted by mightyjo
Originally Posted by Baertram
And, as inventory context menus can get very long due to many addons:
Do you add 2 new entries, 1 each for "Take 1" and "All but 1" or do you use a LibCustomMenu submenu with 2 entries?
The submenu would be a very great thing to keep the base context menu shorter by 1 item).
I'm adding two menu items right now. I limit myself to two total or one primary action and a submenu. If there's a way to compress the primary action and submenu target onto the same line, I'll do that and only take up one space.

So if I can turn
Code:
Take 1
Leave 1
into

Code:
   -- Do the normal Take 1 action
  |     ---- Open the sub-menu
  v    v
Take 1 >      
       Leave 1
please let me know. I'm not seeing a way to make the submenu label perform an action based on where it's clicked.
Not sure if I understand what you mean?
I just meant 1 submenu e.g. named like your addon name
and below that show all possible actions like
"Take / Deposit / Attach 1"
"Leave 1"

And you asked if there is a way to show a submenu and if you click the submenu opening line it would do something (call a callback function)?
That would be possible yes, but only with hacking into ZO_Menu code I'm doing this in FCOItemSaver e.g. to click teh FCOIS submenu opening line and open the LAM settings menu that way / or remove all marker icons.
But that's tricky to do and should not be used for your addon I guess.

One day when I make LibScrollableMenu work with Invenory context menus we will have the possibility to do so more easily! But that's future work
Last edited by Baertram : 07/14/24 at 06:05 AM.
Report comment to moderator  
Reply With Quote
Unread 07/13/24, 04:58 PM  
mightyjo
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 22
Uploads: 2
Originally Posted by Baertram
I think it does but just asking in case it does not (yet): Does your addon support CraftBag stack's "Take 1" and "All but 1" too?
And does it support the "Take 1" and "All but 1" at the normal inventory too?
I hadn't thought to try this. I think the craft bag uses the same API for item movement to & from the backpack so it should work. I'll check.

Originally Posted by Baertram
I often have the problem that I got a stack of items in my inv and only want to kepp 1 or only take 1 to send by mail to friends etc.
Would be such a timesaver if that works in normal inv too.
Mail attachments use a different set of APIs, but this might be possible. There's very little documentation on them so it won't happen quickly (unless it does).

Originally Posted by Baertram
And, as inventory context menus can get very long due to many addons:
Do you add 2 new entries, 1 each for "Take 1" and "All but 1" or do you use a LibCustomMenu submenu with 2 entries?
The submenu would be a very great thing to keep the base context menu shorter by 1 item).
I'm adding two menu items right now. I limit myself to two total or one primary action and a submenu. If there's a way to compress the primary action and submenu target onto the same line, I'll do that and only take up one space.

So if I can turn
Code:
Take 1
Leave 1
into

Code:
   -- Do the normal Take 1 action
  |     ---- Open the sub-menu
  v    v
Take 1 >      
       Leave 1
please let me know. I'm not seeing a way to make the submenu label perform an action based on where it's clicked.
Report comment to moderator  
Reply With Quote
Unread 07/13/24, 07:14 AM  
InsaneShad0w92

Forum posts: 0
File comments: 43
Uploads: 0
Re: Re: Re: New option

Originally Posted by mightyjo
Originally Posted by mightyjo
Originally Posted by InsaneShad0w92
Hey any thoughts on adding Take All but One option?
... maybe
Yes. Try the 'Leave 1' context menu item.
Yeah tried it, works great, thanks.
Report comment to moderator  
Reply With Quote
Unread 07/12/24, 02:36 PM  
Alessondria

Forum posts: 0
File comments: 102
Uploads: 0
Very nice and useful.
Report comment to moderator  
Reply With Quote
Unread 07/12/24, 12:13 PM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 5097
File comments: 6180
Uploads: 78
I think it does but just asking in case it does not (yet): Does your addon support CraftBag stack's "Take 1" and "All but 1" too?
And does it support the "Take 1" and "All but 1" at the normal inventory too?

I often have the problem that I got a stack of items in my inv and only want to kepp 1 or only take 1 to send by mail to friends etc.
Would be such a timesaver if that works in normal inv too.

And, as inventory context menus can get very long due to many addons:
Do you add 2 new entries, 1 each for "Take 1" and "All but 1" or do you use a LibCustomMenu submenu with 2 entries?
The submenu would be a very great thing to keep the base context menu shorter by 1 item).
Last edited by Baertram : 07/12/24 at 12:16 PM.
Report comment to moderator  
Reply With Quote
Unread 07/12/24, 12:12 PM  
mightyjo
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 22
Uploads: 2
Re: Re: New option

Originally Posted by mightyjo
Originally Posted by InsaneShad0w92
Hey any thoughts on adding Take All but One option?
... maybe
Yes. Try the 'Leave 1' context menu item.
Report comment to moderator  
Reply With Quote
Unread 07/11/24, 05:03 PM  
mightyjo
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 22
Uploads: 2
Re: New option

Originally Posted by InsaneShad0w92
Hey any thoughts on adding Take All but One option?
... maybe
Report comment to moderator  
Reply With Quote
Unread 06/18/24, 11:58 AM  
InsaneShad0w92

Forum posts: 0
File comments: 43
Uploads: 0
New option

Hey any thoughts on adding Take All but One option?
Report comment to moderator  
Reply With Quote
Unread 05/26/21, 12:17 AM  
mightyjo
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 22
Uploads: 2
v1.1.1

Everything is fine. Nothing is ruined. Hope nobody saw that embarrassing display.
Report comment to moderator  
Reply With Quote
Unread 05/25/21, 11:41 PM  
mightyjo
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 22
Uploads: 2
Broke something in v1.1.0

Just broke something. I'll have it fixed in a jiffy.
Report comment to moderator  
Reply With Quote
Unread 05/24/21, 10:42 PM  
arps

Forum posts: 0
File comments: 20
Uploads: 0
thanks

great addon thank you so much!
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: