On Aug 20, 2004, at 1:34 PM, Sherm Pendley wrote:
On Aug 20, 2004, at 3:31 PM, Alan Olsen wrote:
I am opening it as a modal dialog box. What I am trying to do is get
it to act like "OpenPanel" or the alert dialog. Those return to the
calling process when they are done and not before.
That *is* how a modal session acts. For example, let's assume a panel
that's connected to the outlet named MyPanel. In that panel you have a
table view named TableView. In some action method, you open the panel
like this:
my $row =
NSApplication->sharedApplication()->runModalForWindow($self-
>myPanel());
How do you set the datasource for tableview. I usually call it right
after displaying the window. I am not certain what procedure to put it
in since there is not a constructor for the window that I am aware of.
The call to runModalForWindow: won't return until the modal session is
stopped with stopModal, stopModalWithCode:, or abortModal. Let's
assume you want it to return the selected row in TableView. In the
action handler for the OK button, you'd have something like this:
sub okClicked : Selector(okClicked:) ArgTypes(@) ReturnType(v) {
my ($self, $sender) = @_;
my $rowSel = $self->tableView()->selectedRow();
NSApplication->sharedApplication()->stopModalWithCode($rowSel);
}
This does not want to kill the window. I am looking for the description
in the api docs. It looks like it is missing a reference to what
window needs to be destroyed.
It does act as it should, however.
If you need to do something more complex, like return a string or
object, just store it in an instance variable and use stopModal
instead of returning it directly with stopModalWithCode.
I have tried waiting in a loop until a message comes back, but that
gives me the technicolor pizza.
Like I said, that's by design. If you're spinning in a tight loop,
you're not responding to events, and that means pizza.
Mmmm... Pizza....
|