View Single Post
09-21-16, 02:12 PM   #4
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
I wonder why this was changed in Legion though, previously you could just shift-click anything into the search bar but now you need to have it focused first

https://www.townlong-yak.com/framexm....lua/diff#3816
Code:
@@ -3820,15 +3814,13 @@ function ChatEdit_InsertLink(text)
 		end
 		return true;
 	end
-	if ( TradeSkillFrame and TradeSkillFrame:IsShown() )  then
+	if ( TradeSkillFrame and TradeSkillFrame.SearchBox:HasFocus() )  then
 		local item;
 		if ( strfind(text, "item:", 1, true) ) then
 			item = GetItemInfo(text);

This is what I'm using in FixTradeSkillSearch if anyone is interested
Lua Code:
  1. hooksecurefunc("ChatEdit_InsertLink", function(text) -- shift-clicked
  2.     -- change from SearchBox:HasFocus to :IsShown again
  3.     if text and TradeSkillFrame and TradeSkillFrame:IsShown() then
  4.         local spellId = strmatch(text, "enchant:(%d+)")
  5.         local spell = GetSpellInfo(spellId)
  6.         local item = GetItemInfo(strmatch(text, "item:(%d+)") or 0)
  7.         local search = spell or item
  8.         if not search then return end
  9.        
  10.         TradeSkillFrame.SearchBox:SetText(search)
  11.        
  12.         -- jump to the recipe
  13.         if spell then -- can only select recipes on the learned tab
  14.             if PanelTemplates_GetSelectedTab(TradeSkillFrame.RecipeList) == 1 then
  15.                 TradeSkillFrame:SelectRecipe(tonumber(spellId))
  16.             end
  17.         elseif item then
  18.             C_Timer.After(.1, function() -- wait a bit or we cant select the recipe yet
  19.                 for _, v in pairs(TradeSkillFrame.RecipeList.dataList) do
  20.                     if v.name == item then
  21.                         TradeSkillFrame:SelectRecipe(v.recipeID)
  22.                         return
  23.                     end
  24.                 end
  25.             end)
  26.         end
  27.     end
  28. end)
  29.  
  30. -- increase search box width (up from 112)
  31. TradeSkillFrame.SearchBox:SetWidth(200)
  32.  
  33. -- make it only split stacks with shift-rightclick if the TradeSkillFrame is open
  34. -- shift-leftclick should be reserved for the search box
  35. hooksecurefunc("ContainerFrameItemButton_OnModifiedClick", function(self, button)
  36.     if TradeSkillFrame and TradeSkillFrame:IsShown() then
  37.         if button == "LeftButton" then
  38.             StackSplitFrame:Hide()
  39.         end
  40.     end
  41. end)

But the "jumping" to tradeskill part doesn't seem to work anymore in 7.1 when clicking reagents while shift is pressed, maybe have to hook something else now