Skip navigation.
 
mlRe: Launched window not activating
FROM : Ken Tozier
DATE : Mon Apr 11 21:59:24 2005

Joar,

I didn't try the timer thing because it is a long download process
(getting all photos from a camera memory card) I did try to put the
window opening code outside the thread and the downloading code inside
the thread but ran into the same, non-activating window problem.

The only way I've been able to make the window selectable (in the sense
that it can be brought to front through a manual click) is when it's
opened inside the thread.

Clearly I'm doing something wrong but since the code is really simple,
it would indicate a fundamental misunderstanding on my part regarding
how things are supposed to work when you open a window. My expectation
would be that any window opened by any class within an application
would be placed at the front of the window hierarchy unless explicitly
told to do otherwise. Is that correct?

I'm evidently doing something that not only doesn't do this, you can't
even select the dang thing while the download is in progress unless,
the window is opened inside a thread, then it's at least selectable.
(although even with the thread trick, I can't make it frontmost unless
I manually click on it)

I tried to completelhy encapsulate the downloading finctionality inside
my "ICADownloader" class so the only thing the application has to do is
create an instance in my "AppController" class like so

downloader    = [[ICADownloader alloc] init];

That's it. everything else, registering for camera connect events,
displaying download progress windows etc is handled by ICADownloader

Any glaring problems with this?

On Apr 11, 2005, at 2:59 PM, j o a r wrote:

> I wouldn't use a thread for this purpose alone - it doesn't smell
> right.
>
> I would assume that you perform the open+download+close operation in
> one event loop? that is probably why the window doesn't behave like
> you would expect. Try to just launch your download operation on a
> timer. Something like this:
>
> - (void) myConnectionCallback:(id) sender
> {
>    [self doTheStuffToOpenTheWindow];
>
>    [self performSelector: @selector(runDownloadOperation) withObject:
> nil afterDelay: 0.0];
> }
>
> - (void) runDownloadOperation
> {
>    // do whatever you do when you download
>
>    [myWindow close];
> }
>
> And, if the download operation is a long one (long == more than 1 - 2
> second), you should probably place it on a thread, in which case this
> trick with the timer won't be necessary at all. Having the download
> operation on a thread seems like a much better design than the other
> way around. Try to keep all UI operations on the main thread, and all
> other lengthy operations on secondary threads.
>
> j o a r
>
>
> On 11 apr 2005, at 20.31, Ken Tozier wrote:
>

>> Thanks Lorenzo. Threading did the trick!
>>
>> I'm a little confused as to why threading is necessary though. Is it
>> always required to open nib files other than the main nib inside
>> their own thread? If not, why was it necessary for this instance. I'm
>> not doing anything fancy inside my code, just opening a window with
>> [NSWindowController initWithWindowNibName:@"nibName" owner: self];
>>
>> Do you know if there is any documentation that spells out these types
>> of hidden gotchas?
>>

>

Related mailsAuthorDate
mlLaunched window not activating Ken Tozier Apr 11, 17:54
mlRe: Launched window not activating Lorenzo Apr 11, 19:03
mlRe: Launched window not activating Ken Tozier Apr 11, 20:31
mlRe: Launched window not activating j o a r Apr 11, 20:59
mlRe: Launched window not activating Ken Tozier Apr 11, 21:59
mlRe: Launched window not activating Ken Tozier Apr 12, 03:51
mlRe: Launched window not activating Charilaos Skiadas Apr 12, 04:13
mlRe: Launched window not activating Ken Tozier Apr 12, 06:32
mlRe: Launched window not activating Charilaos Skiadas Apr 12, 07:06
mlRe: Launched window not activating Ken Tozier Apr 12, 07:35
mlRe: Launched window not activating Hamish Allan Apr 12, 13:52