Adding text to a window.

Discussion in 'Mac Programming' started by adcx64, Jun 1, 2011.

  1. macrumors 65816

    adcx64

    Joined:
    Nov 17, 2008
    Location:
    Cudi Zone
    #1
    Hi,
    I am setting up a windows to pop up when my app starts. I use interface builder to make a text field, but it can be edited by the end user. how can I add a text field that cannot be editted by the end user, so it displays the same message every time?

    Thank You!
     
  2. macrumors 6502a

    Joined:
    Dec 29, 2009
    #2
    You need to use a label NOT a TextField. You can find the label in the Object Library in Interface Builder (or the integrated Xcode 4 editor ) by searching for 'label.' The user will not be able to edit a label. You can also change the state of a text field by unchecking the enabled check box in the IB Inspector.
    You could also do it like this in code, provided you have an IBOutlet connected to the NSTextField
    Code:
    
    [myTextField setEnabled:NO];
    
    
    NOTE:
    Labels and TextFields are all NSTextFields, the label is usually not changed by the user.
     
  3. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #3
    In IB there should be a Label object you can drag over. It's really just an NSTextField, but configured to be non-editable, non-selectable and no border.
     

Share This Page