Thread Tools Display Modes
06-15-14, 06:37 AM   #1
sercankd
A Murloc Raider
Join Date: Oct 2005
Posts: 4
How to interact with all items

As you know when you shift click any item while auction window is open, it writes item name to search box. what i wanted is make similiar function like this with ALT+click instead of shift click. i managed to hook up items in bags but i want to interact with all items in profession window, bags etc.

i use this to interact with bag items

Lua Code:
  1. function PandaTranslate:AUCTION_HOUSE_SHOW(...)
  2.      self:SecureHook(_G, "ContainerFrameItemButton_OnModifiedClick")
  3.  end
  4.  function PandaTranslate:ContainerFrameItemButton_OnModifiedClick(this, button)
  5.      if (button ~= "RightButton") or (not IsAltKeyDown()) then
  6.          return
  7.      end
  8.     BrowseName:SetText(Item_List[GetContainerItemID(this:GetParent():GetID(), this:GetID())])
  9.  end
since there isnt similiar object to hook in profession window like ContainerFrameItemButton, i couldnt make it work. but i dont just want to hook profession frame, is there anyway to hook all items like this?
  Reply With Quote
06-15-14, 07:48 AM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
You should use HandleModifiedItemClick for this purpose.
Code:
local origHandleModifiedItemClick = HandleModifiedItemClick
function HandleModifiedItemClick(link)
	if not link then
		return false
	end
	if IsAltKeyDown() and GetMouseButtonClicked() == "RightButton" then
		-- do your stuff here
		return true
	end
	return origHandleModifiedItemClick(link)
end
Note that GetMouseButtonClicked() doesn't work when clicking chat links.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
06-15-14, 08:26 AM   #3
sercankd
A Murloc Raider
Join Date: Oct 2005
Posts: 4
sorry i couldnt make it work, i am new to wow addon making, i just try to make some translation addon for my personal usage

Item_List array works with ID of an item, passing a link to function idk how to handle it
Lua Code:
  1. function HandleModifiedItemClick(link)
  2.     if not link then
  3.         return false
  4.     end
  5.     if IsAltKeyDown() and GetMouseButtonClicked() == "RightButton" then
  6.         BrowseName:SetText(Item_List[GetContainerItemID(this:GetParent():GetID(), this:GetID())])
  7.         return true
  8.     end
  9.     return origHandleModifiedItemClick(link)
  10. end
  Reply With Quote
06-15-14, 11:40 AM   #4
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Okok, no problem. You can extract the ID from a link like this:
Code:
local itemID = tonumber(strmatch(link, "item:(%d+)"))
It will probably error if you try with things that aren't really items. If you want to avoid that you can check whether strmatch returns anything before passing it to tonumber.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
06-16-14, 01:55 AM   #5
sercankd
A Murloc Raider
Join Date: Oct 2005
Posts: 4
Thank you it works pretty well with bag items like i did before but not with profession frame items. when i click skill reagents nothing happens
  Reply With Quote
06-16-14, 04:18 AM   #6
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
I have a feeling that'll be due to those frames not being registered for right clicks, which sadly is the case for most frames that don't use right clicks. Not much to do about it short of explicitly registering right clicks on the buttons in question.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
06-16-14, 04:25 AM   #7
sercankd
A Murloc Raider
Join Date: Oct 2005
Posts: 4
Thank you again, i managed to write workaround for that. I just solved with ingame command
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to interact with all items


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off