ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   How to create an item tooltip (https://www.esoui.com/forums/showthread.php?t=1985)

klaro00 07/16/14 05:30 PM

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

merlight 07/16/14 06:05 PM

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.

Garkin 07/16/14 06:37 PM

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

klaro00 07/17/14 03:22 PM

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


All times are GMT -6. The time now is 09:01 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI