cocoa question/issue - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: cocoa question/issue (/thread-8596.html)
cocoa question/issue - spiralmonkey - Feb 2, 2011 07:24 AM
Hello all. I am porting my Windows screensaver called Dream Aquarium over to mac OSX. I am fairly new to cocoa but have been doing pretty well with the port so far. This screensaver is quite involved and has its own gui interface for adjusting parameters, adding fish, managing fishtanks etc… It's all openGL using the screensaver framework (based on Cocoa's ScreenSaverView class which is a subclass of NSView) and I am capturing and processing all the keyboard and mouse events.
The issue I'm struggling with is being able to opening a file requester from the screensaver (for the user to choose images). I can open an NSOpenPanel but it puts the panel on the desktop, underneath my fullscreen openGL window so it's inaccessible. My solution to that was to miniaturize the screensaver (to temporarily reveal the desktop and file requester) and then de-minaturize it after the user chooses the file. The problem I'm getting is that when the desktop/filerequester is shown, if the user clicks anything on the desktop outside of the file requester, my screensaver seems to receive a shut-down (stopAnimation) signal. I'm not knowledgeable enough with cocoa to determine what event or action message the ScreenSaverView might be receiving that tells it to shut down. I assume if I could capture this event or action message I could prevent the shutdown? I feel like I'm fighting the ScreenSaverView's natural tendency to shut off.
-Does anyone have insight as to what event or action the ScreenSaverView may be receiving? How I could go about determining this? Is there some way to monitor all the events and action messages that ScreenSaverView is getting?
-Am I even going about this the right way? Is there a way to put the file requester right on my fullscreen OpenGL window?
Thanks all for any response.
RE: cocoa question/issue - OneSadCookie - Feb 2, 2011 10:08 AM
You're doing it wrong. Put your UI in the screensaver settings panel where it's supposed to be, and don't try to handle events while the screensaver is running.
RE: cocoa question/issue - spiralmonkey - Feb 2, 2011 10:22 AM
I realize that's the usual way of doing things, but I (and my users) enjoy the interactive aspect of the screensaver and the instant feedback of being able to feed and add fish, manipulate tanks, change camera angles etc... while the action is happening. I already have the whole in-screensaver gui working fine, it's only when I need to open a file requester that the problem happens. If you want to take a look at how it works on Windows, you can check it out here: dreamaquarium.com
RE: cocoa question/issue - skyhawk - Feb 2, 2011 10:47 AM
Yes, but that's now how things are done here.
On macs, your users will be mac users, and thus do things the mac way.
RE: cocoa question/issue - spiralmonkey - Feb 2, 2011 01:31 PM
I should really call this a virtual aquarium rather than a screensaver, it just happens that it kicks in when the computer is idle. Part of its purpose is to be an interactive experience - something my users really like about it. This quality would be lost if everything were done in a settings panel. This was one of my philosophies when I started out - that the user can meddle with the aquarium settings while they see it change in front of them, much like a real aquarium. You can interactively select fish from a palette and you see them swim in to the tank as you select them, or alternately pick specific fish in your tank to delete and see them disappear mid-swim. You can drop in food and in the future, tap on the glass and have the fish scatter. Also, I'd like to have one gui across all platforms (and eventually linux) so that there is a unified way of doing things for all users regardless of OS. I admit/know it's not the normal or mac-specific way of doing things, but I think the end user experience is worth the breach of protocol. Isn't interactivity and tactile manipulation part of the mac philosophy and user experience as well? I guess the idea here is to not actually think of it as a screensaver if that helps.
RE: cocoa question/issue - OneSadCookie - Feb 2, 2011 03:17 PM
Then implement it as an app which happens to have an "activate after delay" feature. Plus that way you can sell it on the MAS.