Thread Tools Display Modes
07/16/14, 05:30 PM   #1
klaro00
 
klaro00's Avatar
Join Date: Apr 2014
Posts: 31
How to create an item tooltip

Hi,

I's like to show an item tooltip (when hovering over certain control). It's not the problem to register the required mouse event listener. What I need is a way to display the tooltip itself when the item (e.g. a potion, a weapon, ...) is given/known, e.g. by an item link or whatever.

I noticed the "TooltipControl" which seems to be fairly complicated for creating a tooltip from scratch. There must be some higher level function(s) from ZO which manages tooltip creation. Also I do want to look the tooltips not any different, so the best would be to use existing ZO code. But I can't find any code example or other hint. I searched half of the Internet, I promise

Cheers,
Klaro
  Reply With Quote
07/16/14, 06:05 PM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
For item info, there's preconstructed ItemTooltip. You can find examples in ZOS UI scripts, if you can get those.
Lua Code:
  1. -- InitializeTooltip(tooltipControl, [anchorControl, anchorPoint, offsetX, offsetY])
  2. InitializeTooltip(ItemTooltip)
  3. ItemTooltip:SetBagItem(bagId, slotIndex)
  4. ClearTooltip(ItemTooltip)
There's a bunch of :Set* methods that fill the tooltip with appropriate info; since addon's don't have access to most of tooltip's contents, so you can't just put anything you want in there.
Also you can check addons like this one to see how you can add simple text lines to the bottom.
  Reply With Quote
07/16/14, 06:37 PM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
As merlight said, when you want to show tooltip call (arguments in square bracket can be nil):
Code:
InitializeTooltip(tooltipControl, [owner, point, offsetX, offsetY, relativePoint])
and then set item information using one of the set methods:
Code:
tooltipControl:SetLink(itemLink)
tooltipControl:SetBagItem(bagId, slotIndex)
When you want to close tooltip, call:
Code:
ClearTooltip(tooltipControl)
You can use one of existing tooltips (ItemTooltip, PopupTooltip, ...) or create your own, but using of the existing tooltip is easier.

Lua Code:
  1. local function ShowTooltip(self)
  2.    InitializeTooltip(ItemTooltip, self)
  3.    ItemTooltip:SetLink(itemLink)
  4. end
  5.      
  6. local function HideTooltip(self)
  7.    ClearTooltip(ItemTooltip)
  8. end
  9.      
  10. yourControl:SetHandler("OnMouseEnter", ShowTooltip)
  11. yourControl:SetHandler("OnMouseExit", HideTooltip)

Similar topic:
http://www.esoui.com/forums/showthread.php?t=1647
  Reply With Quote
07/17/14, 03:22 PM   #4
klaro00
 
klaro00's Avatar
Join Date: Apr 2014
Posts: 31
Thanks & works! Didn't realize that "ItemTooltip" is a predefined tooltip control (I started to create & configure my own tooltip control, then I saw ItemToolTip is one of many prefined ones, and now it looks perfect).

Thanks for your help.

// Klaro
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » How to create an item tooltip


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