• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
input requested : toggling always on top state of window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >[Q] Cocoa newbie question (From: Steve Christensen <email@hidden>)
 >Re: [Q] Cocoa newbie question (From: Sherm Pendley <email@hidden>)
 >Re: [Q] Cocoa newbie question (From: James Chen <email@hidden>)
 >Re: [Q] Cocoa newbie question (From: Steve Christensen <email@hidden>)

  • Prev by Date: Re: [Q] Cocoa newbie question
  • Next by Date: Re: How Do I kill a process from Cocoa?
  • Previous by thread: Re: [Q] Cocoa newbie question
  • Next by thread: Re: Problem with NSOutlineView::shouldSelectItem: and NSRunCriticalAlertPanel
  • Index(es):
    • Date
    • Thread