View Single Post
10-16-14, 02:21 PM   #26
another
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 11
Slightly changed solution without ActionButton hacks. Used HookScript "OnEnter" for MountJournal list buttons.

Set hooks "OnEnter"
Code:
local function HookOnEnter(self)
	local spellID = self:GetParent().spellID
	local index = self:GetParent().index
	--print("HookOnEnter index ", index, " spellID", spellID)
	FlyoutButton_MountJournalIndexToSpellID[index] = spellID
end

local MountButtonsHookIsSet

local function SettingsHookFunc()
	hooksecurefunc("TogglePetJournal", function()
		if PetJournalParent:IsShown() then
			--print("PetJournalParent:IsShown")
			if not MountButtonsHookIsSet then
				--print("Looking for mount buttons")
				for i = 1, 20 do -- I see 12
					local bName = "MountJournalListScrollFrameButton"..i
					--print(bName)
					local f = _G[bName]
					if f then
						--print("Button "..bName.." found")
						if f.DragButton then
							--print("f.DragButton found")
							f.DragButton:HookScript("OnEnter", HookOnEnter)
						end
					end
				end
				MountButtonsHookIsSet = true
			end
		end
	end)
end
call SettingsHookFunc on init somewhere.

Code:
FlyoutButton_MountJournalIndexToSpellID = {}
local FlyoutButton_MountJournalUselessIndexToIndex = {}

local function HookSecureFunc_C_MountJournal_Pickup(Index)
	local _, UselessIndex = GetCursorInfo()
	if (Index and UselessIndex) then
		FlyoutButton_MountJournalUselessIndexToIndex[UselessIndex] = FlyoutButton_MountJournalIndexToSpellID[Index]
		--print("Index", "UselessIndex", Index, UselessIndex)
	end
end
hooksecurefunc(C_MountJournal, "Pickup", HookSecureFunc_C_MountJournal_Pickup)

function FlyoutButton_GetCursorValues()
	local command, value, subValue, id = GetCursorInfo()
	--print("GetCursorValues ", command, value, subValue, id)
	if (command == "spell") then
		-- do whatever with other types
	elseif (command == "mount") then
		command = "spell"
		id = FlyoutButton_MountJournalUselessIndexToIndex[value] -- here is spellID
		value = FlyoutButton_GetGenericSpellNameById(id)
		subValue = "MOUNT"
		--print(command, value, subValue, id)		
	end
	return command, value, subValue, id
end
Here is the way to get spellID. I'm still using it through attributes "spell" etc. And rename "FlyoutButton" stuff since it's directly from my addon. Works in current "FlyoutButton Custom" v2.63
So if something not works for you - see my sources.