🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
2 messages
2 total messages Started by Anees Munshi Fri, 04 Sep 1992 21:40
How to hide on auto-launch?
#744
Author: Anees Munshi
Date: Fri, 04 Sep 1992 21:40
17 lines
892 bytes
I'm trying to implement something like a hide-on-auto-launch
feature, so I need to detect if the application was
auto-launched by the Workspace. 

I tried reading NXArgv, but discovered it is stripped by the
+initialize method of the Application class.

I have read something in the Concepts doc about an NXAutoLaunch
"parameter".  However, there was no further reference to it. 

I can think of some inelegant ways of finding out if the app
was auto-launched, but I'd like to think there is a better way.

I'd appreciate any pointers on this one.

Thanks in advance. -Anees Munshi (asm@eecg.toronto.edu)
Re: How to hide on auto-launch?
#765
Author: Sam Streeper
Date: Sat, 05 Sep 1992 16:17
54 lines
2026 bytes
Anees Munshi writes:
> I'm trying to implement something like a hide-on-auto-launch
> feature, so I need to detect if the application was
> auto-launched by the Workspace. 
> I'd appreciate any pointers on this one.

Here's the code I use to do this.  It could be argued that the proper
app architecture has you deferring the creation of any UI elements
(like loading a nib file) until the app gets unhidden.  However, if you're
lazy, you might keep app state only in the UI and not in other variables,
and thus you are dependent upon the existence of the UI and must create it
in order to initialize your app.

- appDidInit:sender
{
	const char *autoLaunch;
	
	autoLaunch = NXGetDefaultValue([NXApp appName], "NXAutoLaunch");
	if (strcmp(autoLaunch,"YES"))
	{
		[myWindow makeKeyAndOrderFront:self];
		windowHasBeenDisplayed = YES;
	}
	else [NXApp hide:self];
	
	return self;
}

- appDidUnhide:sender
{
	if (!windowHasBeenDisplayed)
	{
		[myWindow makeKeyAndOrderFront:self];
		windowHasBeenDisplayed = YES;
	}
	return self;
}


Here I should probably note that I have seen a NeXT FAQ that says that sending  
a "hide:" message from within "appDidInit:" doesn't work (although it works  
fine for me) and that several NeXT apps have been doing this all along.

Note too that if you do this, you should probably make your main nib
display no windows when it gets loaded (do this manually with  
"makeKeyAndOrderFront") because otherwise they will flash when they
get hidden.

-sam


--
Opinions expressed herein are not those of my employer.  They're not even
mine.  They're probably wrong besides.  How did they get in here, anyway?
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads