How come using setLevel: won't make the window higher than a full screen game? - objective-c

Most games (if not all) do not use Lion's full screen feature. They make themselves full screen using an unofficial method. The problem is - no matter how high I set the level of a window (I'm currently using level 25 - making the window higher than the status bar and its icons) it won't appear over the game. I want to achieve an effect similar to Steam's full screen overlay in game. Is this possible?

Full-screen games typically aren't windows at all. Most such applications are using CoreGraphics to capture the display (see CGDisplayCapture), bypassing window compositing entirely. (So you can't display content on top of them.) Note that this is perfectly "official" -- it's just a different approach from full-screening a window.
Steam works by having the Steam launcher inject code into the application to display the status popup. It isn't a technique that can -- or should -- be used in more general cases.

Related

How do you hide the menu bar in a Cocoa app?

How do you programmatically hide the menu bar in a cocoa app? I would like to make full use of the screen area.
There are two good ways I know of to do this.
1
In Cocoa, you can call the NSMenu class method setMenuBarVisible: to show or hide the menu bar.
As of this writing, the documentation for the NSMenu class does not tell you the following additional information.
The menu bar will only be hidden for the app that calls this method.
The Dock will also be hidden at the same time.
(This is true at least in 10.9 and I have not tested any other versions.)
This is useful when you want to use an app in a full screen way where you have a cover window, a borderless window the size of the screen.
The nice feature of this (as opposed to playing with LSUIElement settings) is that your app can continue to be in the application switcher cycling, as well as visible in the Dock when other apps are active.
This allows users to still activate a full screen app through the Dock or application switcher.
That means you can still use your app's Dock menu to access a preferences window for your app or other features.
This is incredibly convenient if your app is indeed a full screen cover window that runs at a window level higher than other apps, but you still want to make preferences and the ability to quit your app available, and you want your app's visual functionality available when other apps are active.
2
Another option is via NSApplication's method setPresentationOptions: with the arguments from NSApplicationPresentationOptions enum, such as option NSApplicationPresentationHideMenuBar
With this approach be very wary of reading the documentation, although it gives you additional options, and is still app-specific only, you need to know that some of the options are mutually exclusive. There are rules you must follow, or you get nothing but exceptions spewed to the console.
3 There is a 3rd and crappy option. If you have a helper app that is a daemon, you can use it to change your app's LSUIElement state and basically relaunch your app. It's dumb and it takes you out of the app switcher completely, which is great if you really are writing something that should not be there, but that is rare.
There is also the NSView enterFullScreenMode:withOptions: method, although most apps for which that would be appropriate prior to 10.7 should probably use the modern full-screen-window API on 10.7 and later.

Objective-C Lion Fullscreen use all monitors

We have 4 monitors on a wall for graphing. Looking to put them all into use in fullscreen mode. Right now if I do it it just uses one. Just looking to see if it is possible to create an app that allows me to use all 4 with like a simple uiwebview for each monitor.
Should of mentioned this.. Looking for a simple code sample of how to do this or pointers on where to get answers.
Yes, it is possible.
Standard Lion fullscreen mode allows for one "primary window", which is sized to take up the entire main screen, and as many "auxiliary windows" (inspector panels, etc.) as you want, which are not automatically sized in any way.
Go into Xcode, create a simple project, and edit the xib. For the existing window, go to the Attributes Inspector and make sure that Full Screen is set to "Primary Window". Now in the object browser, drag three Panels into the app. Go through them and make sure each one has "Utility Panel" for Style, "Auxiliary Window" for Full Screen, and either "Inferred Behavior" or "Transient Behavior" for Exposé. Now, when the first window goes into full screen mode (e.g., when you get the appropriate notification or NSWindowDelegate method), size and move the other three windows to take over the other three screens.
This is all documented pretty well in the Implementing the Full-Screen Experience section of the "Mac App Programming Guide" in the 10.7 Core Library.
If you're just looking to put a web view on each screen, it may be easier to use -[NSView enterFullScreenMode:withOptions:]. This isn't Lion's new full-screen mode, it's the earlier technique. It has different behavior in terms of whether the app is in a separate space, etc.

Cover screen with window in cocoa

I am writing a Mac application, in Cocoa, that needs the ability to 'lock down' the computer. Basically, I am writing a small agent that will sit in the background and when prompted, throw up a window that covers the entire screen, including the status bar, and shows a message (something like "give me back my computer, thief!").
The window has two requirements: it can't be moved and it can't be closed, minimized or otherwise disabled - just a big blob sitting on the screen, making sure the thief can't use the computer. I have all the agent stuff lined up, but I need help coding this window. Does anyone have any ideas?
Thanks,
Chris
P.S - In my dream world, this window would show up even at the login screen. The agent will be running by then, but I am not sure if OS X will allow it...
What you're asking for is basically to turn the user's computer into a not-very-functional kiosk. See also this technote on the same subject.
For display, alternatives to the full-screen view mode described in the Kiosk Mode document include:
Capture all the displays and draw directly to them using Quartz Display Services.
Set your window's frame to the frame of its screen and set its window level really high. You'll need to create one such window per screen.

In a Silverlight 4 (OOB) app can you move the main window in code

In a Silverlight 4 out of browser app (oob) is there any way to programatically move the main window after the application start-up event.
The reason / Use case: A user selects an option on a silverlight desktop gadget app, the apps window grows to accomodate extra details. If the app started very near the right of the screen the details are obscured/ fall off the edge of the screen and the user needs to drag the window to the left. When the window returns to its smaller state it is now positioned to far left so the user needs to drag the window right again. It would be convention for the app to move itself back and forth automatically to accomodate the details.
Thanks.
Avida - yes you can move the MainWindow using Top/Left properties as long as WindowsStartupPosition is Manual
I will leave the answer below to show my shame... sorry I did not read the question properly.
If you mean the position within the web page, yes you can.
Silverlight can execute Javascript on the hosting page to change attributes (including the size or position of the Silverlight plugin itself).
I have used this feature to resize a Silverlight 3 application to fit its content, enabling use of the browser scrollbars to move down a large app (not needed nowadays with full mousewheel support, but the principle is the same).

How to create a Controller to simulate the Springboard feature of the iPhone within your own application

I am trying to design a feature in my application for the iPhone that simulates the Springboard feature (Main menu of the iPhone that allows you to view more apps), or the way Weather application works that allows you to flip between views.
Does anyone have any samples of this how I would go about doing this. It's seems very trivial but I am wondering if I am missing something that is already available either as an Apple example or someone who did a tutorial on this.
The image below show how the user would use it.
alt text http://www.agilitesoftware.com/SpringboardExample.png
As they slide their finger to the right (or left) the other image would begin to show up. And it would animate smoothly. The faster you swiped your finger the faster it would move to the next view.
Update: The other feature is that it should mimic the same feel when you slide your hand across the display that is snaps to the current view into place. It should not keep sliding across if there is more than 1 view to the direction you swiping your finger.
I've seen other applications use this so that is why I am asking.
This is accomplished using the UIScrollView with the pagingEnabled property set to true. Just add each of your views, adjust the contentSize, and it will automatically "page" to the width of the screen across the content.
There is a sample app (with code) with exactly this functionality on the iPhone developer site on Apple.com (I believe it's called "PageControl".) - I'd suggest checking it out.
d.
I'm writing an app that uses a similar UI. As NilObject recommended, we're using a UIScrollView with pagingEnabled=YES.
You may also be interested in this example code involving just two child views. I'm trying it out now; it's an interesting technique but I've had to write some additional special-casing code for some odd situations that resulted.
There's also another question on this site that asks about creating a grid of icons like the home screen.
I would check out Joe Hewitt's code from the Three20 project for this. It provides a nice interface and further refinement of the UIScrollView implemented as TTScrollView and TTScrollViewDelegate, TTScrollViewDataSource.