I believe that it's not possible to make part of the text on the label clickable. However you can add event handlers to the label, so whole label can show tooltip or handle clicks the same way as links in the chat window. If you want just a part of the text clickable, you will need to use text buffer control instead of the label control.
How to make your label clickable (in Lua):
Lua Code:
--get some link to work with
local itemLink = GetItemLink(BAG_WORN, EQUIP_SLOT_MAIN_HAND, LINK_STYLE_DEFAULT)
--create top level window (label must have some top level window as a parent, otherwise label won't be visible)
local tlw = WINDOW_MANAGER:CreateTopLevelWindow()
--create label
local label = WINDOW_MANAGER:CreateControl(nil, tlw, CT_LABEL)
--set some big font
label:SetFont("ZoFontAnnounceMedium")
--set label text
label:SetText(itemLink)
--set label dimensions to fit text size
label:SetDimensions(label:GetTextWidth(), label:GetTextHeight())
--set label anchor to the middle of the screen
label:SetAnchor(CENTER, GuiRoot, CENTER, 0, 0)
--make label visible
label:SetHidden(false)
--enable mouse events for label:
label:SetMouseEnabled(true)
--set handler for mouse enter:
label:SetHandler("OnMouseEnter", function(self)
InitializeTooltip(ItemTooltip, self, BOTTOMLEFT, 0, 0)
ItemTooltip:SetLink(self:GetText())
end)
--set handler for mouse exit:
label:SetHandler("OnMouseExit", function(self)
ClearTooltip(ItemTooltip)
end)
--set handler for mouse click (actually this event is fired when mouse button is released, argument upInside indicated if button was released when cursor is still inside of the control):
label:SetHandler("OnMouseUp", function(self, button, upInside, ctrl, alt, shift, command)
if upInside then
ZO_LinkHandler_OnLinkClicked(self:GetText(), button, self)
end
end)
The same code in XML:
xml Code:
<GuiXml>
<Controls>
<TopLevelControl>
<Controls>
<Label font="ZoFontAnnounceMedium" mouseEnabled="true">
<Anchor point="CENTER" relativeTo="GuiRoot" />
<OnInitialized>
local itemLink = GetItemLink(BAG_WORN, EQUIP_SLOT_MAIN_HAND, LINK_STYLE_DEFAULT)
self:SetText(itemLink)
self:SetDimensions(self:GetTextWidth(), self:GetTextHeight())
</OnInitialized>
<OnMouseEnter>
InitializeTooltip(ItemTooltip, self, BOTTOMLEFT, 0, 0)
ItemTooltip:SetLink(self:GetText())
</OnMouseEnter>
<OnMouseExit>
ClearTooltip(ItemTooltip)
</OnMouseExit>
<OnMouseUp>
if upInside then
ZO_LinkHandler_OnLinkClicked(self:GetText(), button, self)
end
</OnMouseUp>
</Label>
</Controls>
</TopLevelControl>
</Controls>
</GuiXml>