PauseForUser

from the help:

 

During execution of PauseForUser, only mouse and keyboard activity directed toward either mainWindowName or targetWindowName  is allowed.
...
If /C is omitted, PauseForUser returns only when the main window has been killed.

 

I find that if I kill the target window, PauseForUser returns even though the main window is still open.

Is this correct behaviour?

 

 

Well, I took a look at the source code, and it does seem to be written that way. And it appears to be deliberate, which doesn't mean it's not a bug. I guess it could be fixed, but it's no doubt been that way since at least Igor 7, when PauseForUser was completely rewritten to work with the Qt framework.

I think I recognize the signs that you want it to work the way it says in the documentation...

Perhaps you would tell me what the use case is?

I create a panel as a modal settings dialog to change preferences. I'd like an option from within the panel to display a log file as 'target' window - seems reasonable based on the description. But that falls apart when PauseForUser doesn't work as described.

Current options are 1.open the log as a notebook, but because notebooks cannot be target windows the user cannot interact with it until the panel is closed. That's a bit awkward. 2. Open log as notebook embedded in a target panel. But closing the target window leaves my modal dialog stranded. 3. find an alternative pathway for the user to look for the log.

Not a big deal, but I already wrote the code for option 2 without realizing that PauseForUser doesn't do what it says on the can. Hence the question.

I used a window hook as a workaround to reset PauseForUser. It works to create a feature that is unlikely to be used by more than one person. I'm satisfied, and the code should work regardless of which way PauseForUser works.

I am amenable to adding a flag that would make it work the way the documentation implies, but I'm trying to think how this would work. If you do as you say, putting up a target window with the log file in it, and the user closes that window, you can't then create a new target window. Are you saying that in your use case once it's closed, it can just stay that way?

As I suggested before, it sounds like you wouldn't lose anything by simply making the log file notebook a subwindow in the main control panel window.

I wanted to allow the target window to have a life beyond the main window. But a subwindow works fine if I give up on that.

What I was trying to do is perhaps beyond the normal intended purposes of pauseforuser. I should note that if a target window is created after pausforuser is active, I have to kill the main window, recreate the main window, and start pauseforuser with main and target windows specified. That is as expected. And yes, if the target window is closed it can stay that way, I just didn't want the closing of the target window to end pauseforuser, but that was easily fixed with a hook. My reason for using pauseforuser in the first place is that a dialog that changes preferences that affect the way a package functions should be modal. Then I had the dumb idea of adding links to logs in the same dialog....

 

OK, thanks for clarifying that. I think my approach will be to change the documentation!