Thread Tools Display Modes
05/27/14, 08:11 AM   #1
hulksmash
 
hulksmash's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 30
tooltip example

Can anyone provide a clean tooltip example? I want to create a tooltip when you mouse over button texture. I want it to look very similar if not exactly like the tooltips when you navigate the tabs in your inventory and bank. I just want a clean simple box with text inside it. I started making one from scratch but then saw some tooltip controls in the wiki that I couldn't make sense of. I dont want to use any .xml files.
  Reply With Quote
05/27/14, 09:11 AM   #2
ingeniousclown
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 122
Take a look at my Advanced Filters addon, specifically the file "AdvancedFilterGroups.lua". It's pretty simple once you find the correct line (don't have line numbers off the top of my head).
  Reply With Quote
05/27/14, 09:30 AM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by hulksmash View Post
Can anyone provide a clean tooltip example? I want to create a tooltip when you mouse over button texture. I want it to look very similar if not exactly like the tooltips when you navigate the tabs in your inventory and bank. I just want a clean simple box with text inside it. I started making one from scratch but then saw some tooltip controls in the wiki that I couldn't make sense of. I dont want to use any .xml files.
Lua Code:
  1. local function ShowTooltip(self)
  2.    --InitializeTooltip(tooltipControl, [owner, point, offsetX, offsetY, relativePoint])
  3.    InitializeTooltip(InformationTooltip, self, TOPRIGHT, 0, 5, BOTTOMRIGHT)
  4.    --SetTooltipText(tooltipControl, text, [r, g, b])
  5.    SetTooltipText(InformationTooltip, "Some text")
  6.    --or you can use:
  7.    --tooltipControl:AddLine(text, [font, r, g, b, lineAnchor, modifyTextType, textAlignment, setToFullSize]), default font = ""
  8.    --tooltipControl:AddVerticalPadding(offsetY)
  9. end
  10.  
  11. local function HideTooltip(self)
  12.    --ClearTooltip(tooltipControl)
  13.    ClearTooltip(InformationTooltip)
  14. end
  15.  
  16. yourControl:SetHandler("OnMouseEnter", function(self) ShowTooltip(self) end)
  17. yourControl:SetHandler("OnMouseExit", function(self) HideTooltip(self) end)

Last edited by Garkin : 05/29/14 at 12:54 PM.
  Reply With Quote
05/27/14, 01:50 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
I just use the default UI code to do it for me.

Say I want a tooltip for a button...

Lua Code:
  1. button.tooltipText = "My tooltip text!"
  2. button:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter)
  3. button:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)
  Reply With Quote
05/27/14, 03:00 PM   #5
Kentarii
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
Another one, just to give you more to choose from:
Lua Code:
  1. --- Add a tooltip to a control.
  2. -- @param ctrl the control element.
  3. -- @param text the text to show on mouse over.
  4. -- @return void
  5. local function SetToolTip(ctrl, text)
  6.     ctrl:SetHandler("OnMouseEnter", function(self)
  7.         ZO_Tooltips_ShowTextTooltip(self, TOP, text)
  8.     end)
  9.     ctrl:SetHandler("OnMouseExit", function(self)
  10.         ZO_Tooltips_HideTextTooltip()
  11.     end)
  12. end
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » tooltip example


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