RE: Gray background behind app windows?
Duncan Champney <[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
Begin forwarded message: > From: Christiaan Hofman <[email protected]> > Date: September 19, 2009 3:57:42 PM EDT > To: Duncan Champney <[email protected]> > Cc: [email protected] > Subject: Re: Gray background behind app windows? > > > On Sep 19, 2009, at 21:12, Duncan Champney wrote: > >> >> On Sep 18, 2009, at 3:00 PM, [email protected] wrote: >> >>> From: Duncan Champney <[email protected]> >>> Date: September 18, 2009 2:18:39 PM EDT >>> To: [email protected] >>> Cc: Steve Sheets <[email protected]> >>> Subject: Gray background behind app windows? >>> >>> >>> Folks, >>> >>> Apps like Photoshop (PS) used to have an option to blank out the >>> desktop behind their windows to a flat gray. That reduced visual >>> clutter so artists could focus on the app's windows. >>> >>> I have Photoshop CS3, not CS4 (I tend to update every other time >>> to try to save a little money) so I don't know how it works in >>> CS4, but in CS3 under Leopard, it looks like PS turns the document >>> window into a "super window" that fills the whole screen and has >>> gray borders all the way around. >>> >>> Our company is working on rewriting a legacy OS 7/8/9/ app for OS >>> X (>= 10.5), and the legacy app has the option to blank out >>> everything behind the app's windows to dull gray. >>> >>> Does anybody know a way to do this in OS X without either going to >>> full-screen mode (and losing Cocoa's support for document windows, >>> tool palettes, etc.) or turning the front document into a monster >>> that takes up the whole screen, with the content placed in a >>> resizeable view in the middle? That's doable, but less elegant >>> than the gray background old OS 9 apps used to use, and doesn't >>> allow the user to see more than one document window at a time. >>> >>> >>> >>> Thanks in advance, >>> >>> Duncan C >>> WareTo LLC >>> >>> >>> >>> >>> >>> >>> >>> From: Kyle Sluder <[email protected]> >>> Date: September 18, 2009 2:56:29 PM EDT >>> To: Duncan Champney <[email protected]> >>> Cc: [email protected], Steve Sheets <[email protected]> >>> Subject: Re: Gray background behind app windows? >>> >>> >>> On Fri, Sep 18, 2009 at 11:18 AM, Duncan Champney >>> <[email protected]> wrote: >>>> Does anybody know a way to do this in OS X without either going to >>>> full-screen mode (and losing Cocoa's support for document >>>> windows, tool >>>> palettes, etc.) or turning the front document into a monster >>>> that takes up >>>> the whole screen, with the content placed in a resizeable view in >>>> the >>>> middle? That's doable, but less elegant than the gray background >>>> old OS 9 >>>> apps used to use, and doesn't allow the user to see more than one >>>> document >>>> window at a time. >>> >>> Create a screen-sized NSWindow and set its level using -[NSWindow >>> setLevel:]. >>> >>> --Kyle Sluder >>> >>> >> >> >> Kyle, >> >> What level should I use? I would want the gray window to be behind >> all of my app's other windows, but in front of other apps and in >> front of the desktop. I could not find a level value for setLevel >> that would do what I needed. I tried most of the different >> available level settings, but no luck. > > First of all: just think. Most windows are at NSNormalWindowLevel, > and utility windows etc are at NSFloatingWindowLevel. So it should > be obvious that you can't just get what you want by simply setting > the window level of the gray background window. You should move both > this window and all your apps window to a higher level, at least > higher than NSFloatingWindowLevel. > > But you have to be careful about that. Certainly it's a bad idea to > move anything higher than the Force Quit window (which IIRC is > usually placed at NScreensaverWindowLevel, though this is buggy on > 10.5.x). > > There is no clear cut answer, it really depends on how important it > is which other windows should be covered. It is not necessarily true > that it MUST cover all other app's windows. Remember, you're not a > screen dictator, users may find it very rude when you completely > prevent other apps from becoming visible. In most situation in fact > the best is to simply use NSNormalWindowLevel, but then you probably > want to make sure all your apps windows are moved to the front when > your app becomes active. > >> >> Right now I am working on creating a screen-sized window with >> styleMask: NSBorderlessWindowMask, at the default level for my app, >> then using -orderBack to put it behind my other app windows. >> >> The problem with that is that if I click on the gray window, the >> system brings it in front of my other app windows. I tried >> overriding NSWindow's -mouseDown method and having that method do >> nothing, but the system still brings the gray window to the front. >> >> How would I get the system to ignore mousedowns in the window so it >> does not get moved to the front? >> >> >> Duncan > > You probably want to override canBecomeKeyWindow and > canBecomeMainWindow to return NO, and you may also want to use > setIgnoresMouseEvents:. > > Christiaan > Christiaan, Thanks for your suggestions. I didn't know much about window levels until somebody else suggested using that approach. After reading about setLevel and experimenting with it, I concluded that it wasn't going to do what I needed without doing something like you suggested, raising the level of all my app's windows. That seems like it is too likely to cause unwanted side- effects. I really want my gray window to be at the normal window level, but always be the LAST window at that level. If I could place it using orderLast, then get it to swallow mouse events, I should get exactly the effect I am after. I am creating the window as styleMask: NSBorderlessWindowMask, which causes the window to not have a title bar. According to the documentation on canBecomeKeyWindow and canBecomeMainWindow, the default version of those methods returns false for windows that don't have a title bar. I just tried using setIgnoresMouseEvents: TRUE. It keeps the window from responding to mouse events, but it causes it to become transparent to mouse events. If I click on the gray area, the mouse click passes through my app and brings up whatever other app is hidden behind my gray window. I would have thought that implementing a do-nothing mouseDown method for my custom window sub-class would do the trick. It looks like the system is handling the click first, doing window ordering, and THEN passing the event to my window. I need some way to tell the system not to bring my window to the front when the user clicks on it. Regards, Duncan WareTo