input requested : toggling always on top state of window
input requested : toggling always on top state of window
- Subject: input requested : toggling always on top state of window
- From: Mike Chambers <email@hidden>
- Date: Wed, 10 Dec 2003 21:50:59 -0800
Hi, I am just learning Cocoa, and am building my first simple
application. I added some code and a menu item that toggles Always on
Top behavior for my window.
The code is below, and works fine, but I was curious if there was a
better way for me to do this.
I would appreciate any input, thoughts, suggestions:
-------
//IBOutlet NSMenuItem *alwaysOnTopMenuItem;
//called when the always on top menu item is selected
- (void)onAlwaysOnTopMenuSelect:(id)anItem
{
//alwaysOnTopMenuItem
NSImage *curImg = [alwaysOnTopMenuItem image];
NSImage *newImg;
int windowLevel;
if(curImg == [alwaysOnTopMenuItem onStateImage])
{
newImg = [alwaysOnTopMenuItem offStateImage];
windowLevel = NSNormalWindowLevel;
}
else
{
newImg = [alwaysOnTopMenuItem onStateImage];
windowLevel = NSScreenSaverWindowLevel;
}
[alwaysOnTopMenuItem setImage:newImg];
[mainWindow setLevel:windowLevel];
}
-------
Thanks...
mike c
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.