Event Chaining
Hi,
i try to attach actions to already defined ui event, for example inventory tab clicks, without killing the already assigned actions. I saw a solution inside the InventoryMod (by Cr4x) ;) but it looks cumbersome and may fail once another addon uses its own event storage. The PreHookHandler, however, is not suitable in this scenario. lua Code:
|
To your example, I could be wrong, but I think the problem is you're not giving it anything to do.
-- SetHandler(string handlerName, function functionRef) When I've used handlers before I haven't had any issues, though, it is possible the ones I've needed didn't already use the event I did. I would think the way you would want to write it though, would be: Code:
ZO_PlayerInventoryTabsButton7:SetHandler("OnMouseUp", function(self) addonName:SomeFunction() end) EVENT_GLOBAL_MOUSE_UP (integer button, bool ctrl, bool alt, bool shift, bool command) I believe it would be: Code:
EVENT_MANAGER:RegisterForEvent(addonName .. "_OnMouseUp", EVENT_GLOBAL_MOUSE_UP , function(...) self:OnMouseUpHandler(...) end) Code:
ZO_PlayerInventoryTabsButton7:SetHandler("OnClicked", function(self) addonName:SomeFunction() end) |
Thanks for the examples. The OnMouseUp, kills the default operation, OnClicked is ignored. Maybe there's just something wrong with my event handler assignment:
lua Code:
|
I believe the "OnClicked" will only work if it is a CT_BUTTON. Beyond that, you'll probably have to wait for someone more experienced to see this. I have not needed to use handlers that required parameters to be passed along yet, so not sure if there's anything else wrong with that. Otherwise the code looks right.
Edit: also, I'm not sure if the syntax is correct unless you're calling a global function, but it might need addonName or self for Code:
child:SetHandler("OnClicked", function(self) addonName:BBS_SearchBoxOnTextChanged(bbs.editbox) end) |
The EVENT_GLOBAL_MOUSE_UP did the trick, thanks ;)
Anyway, the event chaining problem still ain't solved (at least for me :p) |
You could try using the ZO built in prehook. As far as I know there is no posthook though so it'll run before the default code does
Lua Code:
|
Quote:
|
Quote:
|
I tried the PreHookHandler but unfortunately the inventory list data is updated afterwards
|
Quote:
You're safer trying to hook closer to the actual source. |
Quote:
I believe I was hooking as close as possible; I configured the prehook for the OnMouseOver handler for the generic ZO_InventorySlot. The problem is that somewhere in ZO's code, where they bind commands to objects for keybind interactions (in this case, pressing 'e' to use an item in the inventory or transfer to and from the bank), the original mouseover handler can call, and in this case, does call, a private/protected function. This would be fine as it's their handler, but once you localize that original handler (for use in a prehooked function, for instance) it becomes part of 'your addon's scope' and thus unsafe code meaning it can no longer run that private/protected function. Or, at least, this is how I am understanding it.... Please do correct me if I am mistaken or missing something! Lua Code:
I've since changed this code to use an existing mouseover event that I have hooked into as the calling function and utilize the moc() functionality instead, alleviating the issue with the private function. |
Quote:
|
Quote:
Quote:
|
Quote:
http://www.esoui.com/forums/showthread.php?t=564 I'm using this solution in my AddOn, but when hooking into some Functions i encountered a problem with "unsafe function call" errors, where hooking into other functions works without problems. So be warned ;) |
Quote:
|
ooops, i think i was a bit to fast with hitting "reply" then ;)
|
All times are GMT -6. The time now is 09:20 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI