They have an OnReceiveDrag, here is an example that prints the name of the inventory item or skill & sets the button texture to that item/skill:
XML:
Warning: Spoiler
xml Code:
<GuiXml>
<Controls>
<TopLevelControl name="TestAddon_Drag" clampedToScreen="true" mouseEnabled="true" movable="true" hidden="false" resizeHandleSize="12">
<Dimensions x="64" y="64" />
<Anchor point="CENTER" offsetX="0" offsetY="0" />
<Controls>
<Button name="$(parent)Button" clampedToScreen="true" mouseEnabled="true" layer="1" level="1" tier="1">
<AnchorFill />
<OnInitialized>
self:GetParent().btn = self
</OnInitialized>
<OnReceiveDrag>
TestAddon.OnDragReceive(self)
</OnReceiveDrag>
</Button>
<Backdrop name="$(parent)BG" inherits="ZO_DefaultBackdrop" hidden="false" alpha="1" layer="0" level="0" tier="0" >
<AnchorFill />
<OnInitialized>
self:GetParent().backdrop = self
</OnInitialized>
</Backdrop>
<Texture name="$(parent)Icon" clampedToScreen="true" hidden="false" >
<Anchor point="TOPLEFT" relativeTo="$(parent)" offsetX="4" offsetY="4"/>
<Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" offsetX="-4" offsetY="-4"/>
<OnInitialized>
self:GetParent().icon = self
</OnInitialized>
</Texture>
</Controls>
</TopLevelControl>
</Controls>
</GuiXml>
Lua:
Warning: Spoiler
Lua Code:
local MY_CURSOR_INFO = {}
local function OnReceiveDragInventoryItem(self)
local bagId = GetCursorBagId()
local slotIndex = GetCursorSlotIndex()
-- Do whatever
local name = GetItemName(bagId, slotIndex)
local icon = GetItemInfo(bagId, slotIndex)
self:GetParent().icon:SetTexture(icon)
d("Bag Item: "..name)
-- when done with cursor item:
ClearCursor()
MY_CURSOR_INFO = {}
end
local function OnReceiveDragAction(self)
-- Do whatever
local name, icon = GetSkillAbilityInfo(MY_CURSOR_INFO.skillType, MY_CURSOR_INFO.lineIndex, MY_CURSOR_INFO.index)
local msg = zo_strformat("<<1>>: <<2>>, <<3>>, <<4>>", name, MY_CURSOR_INFO.skillType, MY_CURSOR_INFO.lineIndex, MY_CURSOR_INFO.index)
self:GetParent().icon:SetTexture(icon)
d(msg)
-- when done with cursor item:
ClearCursor()
MY_CURSOR_INFO = {}
end
function TestAddon.OnDragReceive(self)
local cursorContentType = GetCursorContentType()
if cursorContentType == MOUSE_CONTENT_INVENTORY_ITEM then
OnReceiveDragInventoryItem(self)
elseif cursorContentType == MOUSE_CONTENT_ACTION then
OnReceiveDragAction(self)
end
end
local function OnActionDragStart(control)
if(GetCursorContentType() == MOUSE_CONTENT_EMPTY) then
if not ZO_Skills_AbilityFailsWerewolfRequirement(control.skillType, control.lineIndex) then
MY_CURSOR_INFO.skillType = control.skillType
MY_CURSOR_INFO.lineIndex = control.lineIndex
MY_CURSOR_INFO.index = control.index
end
end
end
ZO_PreHook("ZO_Skills_AbilitySlot_OnDragStart", OnActionDragStart)
EDIT: You don't have to do it with xml. You could set the handler with lua also:
Lua Code:
TestAddon_Drag:SetHandler("OnReceiveDrag", TestAddon.OnDragReceive)