Search Unity

GUI.tooltip only available in EventType.Repaint

Discussion in 'Immediate Mode GUI (IMGUI)' started by nafonso, Feb 17, 2008.

  1. nafonso

    nafonso

    Joined:
    Aug 10, 2006
    Posts:
    377
    Hi,

    Is there a reason for GUI.tooltip only being available in EventType.Repaint? The reason I'm asking is because I wanted to see if a mouse clicked on a gui element once or twice, and to know if it is with the mouse over, I used tooltip. However, the clickCount is only available in EventType.MouseDown, which means that they aren't both active at the same time.

    Do I have to workaround this situation?

    Regards,
    Afonso
     
  2. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Yes - for performance, we don't always record it (and sometimes we don't even know!), so you need to cache it in a local string.

    But isn't what you want something like
    if (GUILayout.Button ("DoubleClick Me!") Event.current.clickCount == 2)
     
  3. nafonso

    nafonso

    Joined:
    Aug 10, 2006
    Posts:
    377
    Well, for the click count I could surely use that, it's just my mind hasn't got quite use to something like GUILayout.Button( "click me", "label" ); hehe :wink:

    But I need to use guitooltip also, because I want to select a whole line, which is made of various strings, and I have to use a mechanism to know if I'm hover any of them to highlight the others. Here's a screenshot of what I did:


    I got it working with GUILayout.Boxs and MouseDown + clickCount, but since it is kind of ugly, I'll re-implement it with Button just to look cleaner.

    Thanks for the tip!

    Regards,
    Afonso