Author Topic: OnTooltip after clicking a button  (Read 7541 times)

Majicpanda

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
OnTooltip after clicking a button
« on: May 24, 2014, 05:20:52 PM »
When using OnTooltip and clicking a button that has the script on it, the tooltip goes away and doesn't show back up.  I've got skill tooltips for an RPG using this system so I don't want the tooltip to go away at all while hovering the button.  Is there any way to make a tooltip not go away when clicking on a button?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnTooltip after clicking a button
« Reply #1 on: May 25, 2014, 05:34:47 PM »
It's intentional and how tooltips generally behave. Once you interact with the element, you "cancel" the tooltip. Move the mouse away from the button then back onto it and you will see the tooltip show up.

Majicpanda

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
Re: OnTooltip after clicking a button
« Reply #2 on: May 26, 2014, 01:42:46 AM »
Was able to fix it with OnHover to give desired results.

  1.         private bool isMouseOver = false;
  2.  
  3.         void OnHover(bool isOver)
  4.         {
  5.                 // ignore if the mouse is already over - this happens since the OnHover event happens when the button is clicked
  6.                 if (isOver && isMouseOver) return;
  7.  
  8.                 if(isOver)
  9.                 {
  10.                         isMouseOver = true;
  11.  
  12.                         if(TrackedSkill == null)
  13.                                 return;
  14.  
  15.                         string tip = "[FF9900]" + TrackedSkill.skillName+ "[-]\n";
  16.                         tip += "[ffffff]" + TrackedSkill.tooltipDescription(false)+ "[-]";
  17.  
  18.                         if(TrackedSkill.OwnedRank < TrackedSkill.maxRanks)
  19.                         {
  20.                                 tip += "\n\n[cccccc]NEXT RANK[-]\n";
  21.                                 tip += "[FF9900]" + TrackedSkill.skillName+ "[-]\n";
  22.                                 tip += "[ffffff]" + TrackedSkill.tooltipDescription(true)+ "[-]";
  23.                         }
  24.  
  25.                         UITooltip.ShowText(tip);
  26.                         //return;
  27.                 }
  28.                 else
  29.                 {
  30.                         isMouseOver = false;
  31.                         UITooltip.ShowText(null);
  32.                 }
  33.         }
  34.  

Majicpanda

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
Re: OnTooltip after clicking a button
« Reply #3 on: May 26, 2014, 01:59:09 PM »
This doesn't give exactly the intended result... is there any way to update and refresh the tooltip text without it calling a full rebuild of the tooltip and transitioning the size?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnTooltip after clicking a button
« Reply #4 on: May 26, 2014, 11:45:20 PM »
NGUI simply sends the OnTooltip notification. What you do inside this tooltip is up to you. If you want it to watch some object and update the values inside based on some changing data, then you will need to write precisely that logic in your script rather than simply calling UITooltip.ShowText only once. Keep in mind, you can call UITooltip.ShowText multiple times in a row if you want. Also note that the entire UITooltip class is an example that can be modified to fit your needs. For Windward I am using a custom tooltip type for example, as I need to use one label to display the item's name, and another label to display the stats.