Creating button info pop ups

Discussion in 'Mac Programming' started by larswik, Jul 23, 2013.

  1. macrumors 68000

    Joined:
    Sep 8, 2006
    #1
    Can someone steer me in the right direction. I have a Mac app that I am finishing up and I want the user to be able to hover the mouse over a button for a couple seconds and then have a info window pop up to let the user know what that button is for.

    Are there any links or tutorials for this?

    Thanks.
     
  2. macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #2
    You can set a tooltip in the Interface Builder or programmatically by using NSView's setToolTip: method.
     
  3. thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #3
    Thanks! setToolTip looks to be the a good direction to look into and exactly what I need.
     
  4. thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #4
    I just wanted to follow up with some code that made this easy for anyone else looking for information. NSButtons come with a Method called setToolTip. I did not need to create an NSView, it was a simple as...

    Code:
    [myButton setToolTip:@"Hello World"];
    
    After that you just hover the mouse over the button for a couple of seconds and it displayed the text in a yellow box, exactly what I needed and very easy.
     
  5. macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #5
    Don't forget that an object can use methods that it inherits from its parents. The setToolTip method itself is defined in the NSView class, but is inherited by the button (since it has a view).
     
  6. thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #6
    I stand corrected. I thought I was looking in the NSButton Methods and thought I saw setToolTips Method, but I was actually looking in the NSView Class. The code works fine but you are correct, setToolTips is an inherited method from NSView and not in the NSButton Class.

    Thanks!
     

Share This Page