-
Posted by Jacob on Thu, 02 Apr 2009 10:23:27
Hello, everyone.
I wanna have items insertable into an editbox in my addon just like you shift-click them into chat. Unfortunately that doesn't look like default behavior, so pls tell me how to do this?
-
Posted by Jacob on Thu, 02 Apr 2009 10:23:27
Hello, everyone.
I wanna have items insertable into an editbox in my addon just like you shift-click them into chat. Unfortunately that doesn't look like default behavior, so pls tell me how to do this?
-
Posted by jnwhiteh on Thu, 02 Apr 2009 16:43:18
The following code is taken from Clique and does precisely this.
-- Hook the container buttons local containerFunc = function(button) if IsShiftKeyDown() and CliqueCustomArg1 then if CliqueCustomArg1:HasFocus() then CliqueCustomArg1:Insert(GetContainerItemLink(button:GetParent():GetID(), button:GetID())) elseif CliqueCustomArg2:HasFocus() then CliqueCustomArg2:Insert(GetContainerItemLink(button:GetParent():GetID(), button:GetID())) elseif CliqueCustomArg3:HasFocus() then CliqueCustomArg3:Insert(GetContainerItemLink(button:GetParent():GetID(), button:GetID())) elseif CliqueCustomArg4:HasFocus() then CliqueCustomArg4:Insert(GetContainerItemLink(button:GetParent():GetID(), button:GetID())) elseif CliqueCustomArg5:HasFocus() then CliqueCustomArg5:Insert(GetContainerItemLink(button:GetParent():GetID(), button:GetID())) end end end hooksecurefunc("ContainerFrameItemButton_OnModifiedClick", containerFunc) -- Hook the bank buttons local bankFunc = function(button) if IsShiftKeyDown() and CliqueCustomArg1 then if CliqueCustomArg1:HasFocus() then CliqueCustomArg1:Insert(GetContainerItemLink(BANK_CONTAINER, button:GetID())) elseif CliqueCustomArg2:HasFocus() then CliqueCustomArg2:Insert(GetContainerItemLink(BANK_CONTAINER, button:GetID())) elseif CliqueCustomArg3:HasFocus() then CliqueCustomArg3:Insert(GetContainerItemLink(BANK_CONTAINER, button:GetID())) elseif CliqueCustomArg4:HasFocus() then CliqueCustomArg4:Insert(GetContainerItemLink(BANK_CONTAINER, button:GetID())) elseif CliqueCustomArg5:HasFocus() then CliqueCustomArg5:Insert(GetContainerItemLink(BANK_CONTAINER, button:GetID())) end end end hooksecurefunc("BankFrameItemButtonGeneric_OnModifiedClick", bankFunc) -- Hook the paper doll frame buttons local dollFunc = function(button) if IsShiftKeyDown() and CliqueCustomArg1 then if CliqueCustomArg1:HasFocus() then CliqueCustomArg1:Insert(GetInventoryItemLink("player", button:GetID())) elseif CliqueCustomArg2:HasFocus() then CliqueCustomArg2:Insert(GetInventoryItemLink("player", button:GetID())) elseif CliqueCustomArg3:HasFocus() then CliqueCustomArg3:Insert(GetInventoryItemLink("player", button:GetID())) elseif CliqueCustomArg4:HasFocus() then CliqueCustomArg4:Insert(GetInventoryItemLink("player", button:GetID())) elseif CliqueCustomArg5:HasFocus() then CliqueCustomArg5:Insert(GetInventoryItemLink("player", button:GetID())) end end end hooksecurefunc("PaperDollItemSlotButton_OnModifiedClick", dollFunc)
-
Posted by Jacob on Thu, 23 Apr 2009 09:34:53
Found a better solution (for my case):
Old_ChatEdit_InsertLink = ChatEdit_InsertLink
ChatEdit_InsertLink = function(text)
return MyAddon_Edit_InsertLink(text) or Old_ChatEdit_InsertLink(text)
endChatEdit_InsertLink is not a secure function, so just changing it works quite well. I wonder if using hooksecurefunction would be better.
-
Posted by Jacob on Thu, 23 Apr 2009 09:43:03
I wonder if using hooksecurefunction would be better.
Oh, I can answer my own question! Obviously there is no difference provided that no other addon changes hooked function.
-
Posted by jnwhiteh on Thu, 23 Apr 2009 10:03:51
That's not entirely true.. taint is somethign you really need to worry about. A secure hook would be better here, it will allow you to define your own behavior without needing to alter the default UI. That's precisely why I use the method I use.
-
Posted by ALeX-L on Fri, 17 Jul 2009 14:49:56
Have the same problem. Due to my pure knowlege about links, could smb help? Just an example of function to hook a link and paste to editbox. I mean how to catch shift+click on item, spell, another hyperlink etc. and copy a hyperlink.
-
Posted by jnwhiteh on Sun, 19 Jul 2009 12:09:37
Have the same problem. Due to my pure knowlege about links, could smb help? Just an example of function to hook a link and paste to editbox. I mean how to catch shift+click on item, spell, another hyperlink etc. and copy a hyperlink.
We've already provided that in this thread.. haven't we?
-
Posted by ALeX-L on Sun, 19 Jul 2009 15:11:29
Sorry. I've misunderstand smth. What is "CliqueCustomArg1" in that funcs? And where i can see the list of secure functions?
-
Posted by jnwhiteh on Sun, 19 Jul 2009 15:14:34
It's code from Clique.
What exactly are you trying to accomplish. Rather than posting in a closed thread, I would suggest creating a new thread saying exactly what you'd like to do.