On Aug 19, 2004, at 3:21 PM, Alan Olsen wrote:

This is probably a modal v.s. non-modal issue. I want to find out the right way to do it...

I have a window that I display that has a table view. The user needs to select a row off the table.

The problem is that the window is displayed and then the program just keeps on going and does not wait for anything to return.

That's by design. You don't want your program to stop responding to events. If it does, you'll get a "technicolor pizza" cursor after a few seconds.


How do I force the program to wait for an item to be selected before continuing on?

I would open the window in a modal session, either in a sheet or in an app-modal dialog. The window should be designed in Interface Builder with the "OK" button disabled.


In the controller class for your window, selectively enable the "OK" button depending on the number of selected rows in the table view, something like this. (Typed in email, not tested, etc.)

sub validateUserInterfaceItem :
        Selector(validateUserInterfaceItem:)
        ArgTypes(@) ReturnType(c) {

        my ($self, $item) = @_;

        # Assume a connected outlet named $OKButton
        if ($item == $OKButton) {

                # Assume a connected outlet named $TableView
                if ($TableView->rowsSelected() != 0) {

                        # One or more rows selected, enable the OK button
                        return 1;
                } else {

                        # No rows selected, disable OK
                        return 0;
                }
        }

        # You could also add code to validate more controls here, but
        # for this example everything except the OK button is enabled.
        return 1;
}

sherm--



Reply via email to