osx user input

Discussion in 'Mac Programming' started by Nonnus3G, Oct 31, 2008.

  1. Nonnus3G macrumors member

    Joined:
    Jul 9, 2008
    #1
    hello

    i need to get simple user input, lets say a string from a text field
    i wanted to display an alert asking the user to input the info with ok and cancel buttons

    i checked NSAlert and it gives me the popup and the buttons but not text field

    do i need to create a small window with all elements (textfield, button, etc) and display it or is there any builtin UI for this ?
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Yes you need to create your own window. I'd suggest creating a separate nib for the window, and then subclass NSWindowController which handles the nib loading and window displaying.
     
  3. Nonnus3G thread starter macrumors member

    Joined:
    Jul 9, 2008
    #3
    thats what i did :)

    but i included it in the same nib,
    is there any reson why i shouldnt ?
    i reference it and i just use [myWindow orderFrontRegardless] to make it visible...

    however it is not showing with the usual shadow and the ui elements are not working ok,
    the button trigger the assgined IBActions but do not show on press visuals and textfield does not receive text at all although it is set up as editable and selectable in ib (is this correct ?)

    any ideas ?
    or is it related to me simplifying what you mention in your post ?
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    The main reason to use a separate nib is the nib's objects are only loaded when needed, but for most apps it's not that big of a deal.

    I can't really say what's going on with your app without some code. Are you using modal windows?
     
  5. Nonnus3G thread starter macrumors member

    Joined:
    Jul 9, 2008
    #5
    no, not at all

    my app does not even have a main window,
    just menu and status bar item

    in the mainmenu nib i included a NSWindow with desired elements in
    and assigned it to a IBOutlet NSWindow *chosePort
    in ib the window was set up as shadowed, not visible at startup

    i bring up the window with [choosePort orderFrontRegardless];

    but even if i did not have this and made the window appear on start it would have the same weird behavior, no shadow, the buttons dont change visually when pressed and text edit does not receive text (although it changes cursor)
     
  6. Nonnus3G thread starter macrumors member

    Joined:
    Jul 9, 2008
    #6
    i got it displaying ok by messing with ib memory option for NSWindow

    i also started to use [choosePort makeKeyAndOrderFront:nil]
    to force focus on the popup window

    all is good except i am now having a hard time to get the NSTextField content !
     

Share This Page