Cocoa: How do I do that?

Discussion in 'Mac Programming' started by Soulstorm, Apr 28, 2008.

  1. Soulstorm macrumors 68000


    Feb 1, 2005
    I am building a program, and I want to do the following:

    When a user presses a specific button, I want to display some names in a window containing a table view. The user must select one of these names, and he/she must press ok. Then the value selected will be returned, and I must do something with it (which is irrelevant).

    What I don't know is how can I lock the rest of the user interface when displaying this panel. By the time the panel is displayed, I want force the user to make a choice! I don't want the user to be able to tackle with the rest of the user interface until he makes a choice.

    How do I do that? Is there any way that can be done using something else (sheets?)?
  2. Sayer macrumors 6502a


    Jan 4, 2002
    Austin, TX
    Take a piece of paper and draw out the UI you want. Make different versions of it to flesh out the ideas first.

    For example have one larger window with the name-selection at the top and the rest of the UI "hidden" by shrinking the height of the window. When a selection is made expand the window to show the rest of the UI (Like System Preferences).

    Or make one with a sheet blocking the UI.

    Or make something else.

    Make a flow diagram showing the basic steps and see if it makes sense. Then build up a UI and try it out in IB.

    You'd be surprised how many "professionals" draw things out on paper first and make many different test versions of a UI before getting it just right.
  3. robbieduncan Moderator emeritus


    Jul 24, 2002
    You can run any NSWindow as modal via this NSApplication method. Once it's modal you need to have some method that will be called via a UI action that will stop the modal session. Once this is done it's up to you how you get the value back. You could set a variable in the NSWindowController sublcass that owns the modal window as an example.
  4. Soulstorm thread starter macrumors 68000


    Feb 1, 2005
    Hm... That was the answer I was looking for.... Maybe! I will try that and I will post back with the results. Thank you both for your answers.

Share This Page