🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #765

Re: How to hide on auto-launch?

#765
From: 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?
Technical Details
Message-ID: <4931@rosie.NeXT.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!rosie!NeXT.com
References: <1992Sep4.174050.5261@jarvis.csri.toronto.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!rosie!NeXT.com
From: sam_s@NeXT.com (Sam Streeper)
Newsgroups: comp.sys.next.programmer
Subject: Re: How to hide on auto-launch?
Message-ID: <4931@rosie.NeXT.COM>
Date: 5 Sep 92 16:17:03 GMT
References: <1992Sep4.174050.5261@jarvis.csri.toronto.edu>
Sender: news@NeXT.COM
Reply-To: sam_s@NeXT.com
Lines: 54