Basically, I'm making an inventory management addon, and one of the things it will do is have a blacklist and autosell list. They will be managed via multiselect dropdown, where selecting the item means it will be counted in the filter, and deselecting it means it will be ignored (Intended to be a sort of temporarily removing it from the list, but one that will get it's state saved to the DB)
I'm finding it a bit tricky to do this - the logic in my head makes sense, but the API doesn't seem to support this very easily (that I can tell.) Example of the code: http://pastebin.com/34TJe8c3
This has really unexpected results, as it looks like it's printing something out of a hashtable or a memory address for the key parameter, and checked prints "OnValueChanged".
So my first question: How might I go about getting an OnChecked sort of event, with the key that had the state-change (checked/unchecked), so I can handle that?
Second question: Given that the table doesn't seem to contain a checked-state anywhere (It's just a KeyValuePair table where the value is what is printed), I don't see how the state could be saved.
Thanks for any help/advice, and apologies for all the questions today :)
edit: As I had said in another thread, I somehow got this concept working with AceConfig in a version of this addon I made in the past and lost, but I can't for the life of me remember how I got this working. I know I didn't make a custom widget or anything like that. I do remember I had two lists for each "list", one with all the items in it, and one with all the items that were excluded (unchecked)
Callbacks are always called with the widget as the first parameter, and the type of callback as the second.
So a proper signature for your callback function would be function(widget, event, key, checked), where widget == _BlacklistDropdown and event == "OnValueChanged". This would allow re-using the same function for multiple controls, but in your case you could just ignore the first parameters and call it a day.
Well, that makes a LOT more sense. I thought the callback documentation was simply being used on something that passed a widget as the first argument lol.
Thanks for that info, that clears up a lot. I was totally confused. I actually will need that first parameter, because I'm going to have a reusable function for that callback ultimately (there's three different lists that will all have similar logic except for a table name), so actually pretty much what you described it being used as.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I'm finding it a bit tricky to do this - the logic in my head makes sense, but the API doesn't seem to support this very easily (that I can tell.) Example of the code: http://pastebin.com/34TJe8c3
This has really unexpected results, as it looks like it's printing something out of a hashtable or a memory address for the key parameter, and checked prints "OnValueChanged".
So my first question: How might I go about getting an OnChecked sort of event, with the key that had the state-change (checked/unchecked), so I can handle that?
Second question: Given that the table doesn't seem to contain a checked-state anywhere (It's just a KeyValuePair table where the value is what is printed), I don't see how the state could be saved.
Thanks for any help/advice, and apologies for all the questions today :)
edit: As I had said in another thread, I somehow got this concept working with AceConfig in a version of this addon I made in the past and lost, but I can't for the life of me remember how I got this working. I know I didn't make a custom widget or anything like that. I do remember I had two lists for each "list", one with all the items in it, and one with all the items that were excluded (unchecked)
So a proper signature for your callback function would be function(widget, event, key, checked), where widget == _BlacklistDropdown and event == "OnValueChanged". This would allow re-using the same function for multiple controls, but in your case you could just ignore the first parameters and call it a day.
Thanks for that info, that clears up a lot. I was totally confused. I actually will need that first parameter, because I'm going to have a reusable function for that callback ultimately (there's three different lists that will all have similar logic except for a table name), so actually pretty much what you described it being used as.