WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   AH search text addon breaks the auctioneer (https://www.wowinterface.com/forums/showthread.php?t=58075)

alikim 07-02-20 06:49 PM

AH search text addon breaks the auctioneer
 
I want to copy the name of a craftable item from the crafting window to the AH window's search bar, when I click on the items' icon, so I wrote the following macros:


/run TradeSkillFrame.DetailsFrame.Contents.ResultIcon:SetScript("OnClick", function(self, event, ...) local t = {}; C_TradeSkillUI.GetRecipeInfo(TradeSkillFrame.DetailsFrame.selectedRecipeID, t); AuctionHouseFrame.SearchBar.SearchBox:SetText(t.name); end);

It works and does what I want but when I press Search button in the AH window it keeps showing me the yellow rotating circle and nothing happens. The auctioneer stops working altogether and reloading the UI doesn't help - I have to relog to make it work again.

So, what am I doing wrong?

Thank you!

Rilgamon 07-03-20 04:26 AM

You could try to use HookScript instead of SetScript.

alikim 07-03-20 04:43 AM

As I said, the script works, so it's not a problem with attaching a function to a button, which is in a different frame, not the AH one. The AH UI stops working after
Code:

AuctionHouseFrame.SearchBar.SearchBox:SetText(t.name);
Basically, how do you put text into the search text field in the AH window using lua?

Because the line above breaks it to the point that I need to relog to make it work again.

Kanegasi 07-03-20 05:16 AM

The SetScript part isn't going to affect the AH, you're right, but the suggestion is still valid. SetScript replaces whatever function was on that frame while HookScript adds a function to a frame. When dealing with frames you didn't create, especially Blizzard frames, you should use HookScript.

As for your issue, try using the set search function the UI uses instead of setting the text directly, along with nil protection just in case:

AuctionHouseFrame:SetSearchText(t.name or "")


All times are GMT -6. The time now is 03:16 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI