How do I create a preferences window in Objective-C? - objective-c

I would like to create a preferences window like in the standard Mac OS X apps (Safari etc.). I have found resources like DBPrefsWindowController from back in 2008 that matches the Apple HIG.
Just wondering if there is a new way to accomplish this? I can't locate any standard windows in Interface Builder so I assume Apple doesn't provide those, nor can I locate a official Apple sample code for providing this standard UI.
Thank you

It seems DBPrefsWindowController is no longer available.
For now, I would recommend the up to date RHPreferences framework.
Available on GitHub. BSD Licensed.
It’s a simple and easy Preferences window controller with multiple tabs for your next Mac application.
It also provides:
Auto resizing between different sized tab views (With animation)
Custom NSToolbarItem support
Persistence of the last used tab
Support for placeholder NSToolbarItems (eg NSToolbarFlexibleSpaceItemIdentifier & NSToolbarShowFontsItemIdentifier)

Related

Programmatically open NSWindow in another Desktop (Space)

In my OSX Project I want to:
identify the Desktop (one of the expose Spaces) where a NSWindow resides;
open a NSWindow in a determined Space, not only on current Space.
Is there a way to do these simple tasks?
Exploring the documentation (NSWindowController, NSWindow, NSScreen) I can't find anything regarding multiple Desktop Management.
Thanks in advance!
You'd think there would be some API for working with Spaces, but there really isn't. You can use CGWindowListCopyWindowInfo to determine which Space a particular window is on, but there's no easy way to open a particular window on a specific space.
There is private API to move windows between spaces, of course. Whether you want to use this in your application depends on your needs - you couldn't use it on a Mac App Store application, obviously.
Found a copy-of-a-copy of the reverse-engineered header I was looking for:
https://gist.github.com/rjw57/5495406

How to implement the "New Document" window like Pages app does?

As a OS X user, you must be quite familiar with the "New Documents" window when you start some Apple's apps, like Pages.
This window is so common, that I thought it must be some system-provided window, am I right?
I tried to mimic the window, and it turns out to be quite tedious. As a developer, I have to first create a finder-like browser view with list-style selection support. Also, iCloud integration is quite difficult not to mention search support.
So, my question is how can I implement this window, is there any documentation writing about this window? Big thanks!
Look at NSDocument. That is Apple's suggested way of creating document-based apps. You create a subclass of NSDocument to handle tasks specific to your data format, and the superclass handles all the heavy lifting, including iCloud support. I haven't used it myself, but I know that it handles open and save chores, so that's probably where the panel is coming from.
As it turns out, to get this window, all I need to do is to enable iCloud support in Capabilities tab of project properties page.
A little heads up: doesn't work for Swift in Xcode6 Beta. I don't know why to be frankly. And it took me a day to searching around...

Contextual Menu Plugins for Leopard OS

I am writing Contextual Menu Plugins for Leopard OS and referring Writing Contextual Menu Plugins for OS X, part 1 article by Brent Simmons. My plugin is working fine.
Is there any way to move my test menu into main menu (above the Label)?
The short answer is "no".
The OS controls what gets displayed in that menu, so in order to change it around, you would need to call private methods, reimplement system-level functionality, and just in general do some Very Bad Things which would be unsafe, could break at a moment's notice, and possibly work differently between even dot releases of the same OS.
Yes, it's called a system service, and was introduced in OS X 10.5. I know for a fact that many applications can do this, and Automator routines can be triggered this way because Automator itself is a system service. To see a service applicable for an application (i.e. Finder) go to the Application menu on the top bar (for lack of better name T_T), such as the Finder bolded text, and go down to Services > and it will show you all services that can be used in the app. If you need pointers on how to build this, just comment here.
EDIT: Yes, a SIMBL plugin is also considered a service, and on second read of your question, that's what you want.

What programming languages have access to the WinAPI?

I'm looking to start a new programming language and for my first task I want to overlay some text on another applications window, similar to the guy in this post:
Overlay text on some else's window - HUD
Clearly from that post, this can be done in VB.NET, and extrapolating from that, I can probably safely assume that C++\C# can also do this similarly.
My question is; are there any other languages that can do the same? Can Ruby do it? :)
I'm looking for the following capabilities:
Enumerate open windows to find the one I want to overlay on top of.
Overlay text on the 3rd party apps window. (Rich text is a bonus)
Detect window bounds so I can resize the text when the user resizes the window.
Allow click-through of my created text so it doesn't interfere with the 3rd party apps functionality.
Any ideas?
If you want to use Ruby, you have two options: IronRuby and "classic Ruby".
I guess IronRuby would be the preferred option on Windows as it runs on top of .NET and has access to full Windows API through that.
If .NET is too much for your needs and you need to do something simple, then classic Ruby might be a better fit.
For classic Ruby, check out these pages:
Ruby and Microsoft Windows
Microsoft Windows Support
Beware: argument packing and unpacking is not very convenient.

Multiple windows or "pages" in an application

I am a newbie in Mac application development. I want to write a GUI application in Cocoa using Interface Builder. I want multiple screens i.e. when one button on a screen is clicked, another screen should be displayed. How can I activate a new screen at button click event?
I would heartily recommend Aaron Hilegass's book Cocoa Programming for Mac OS X. It took me from feeling like everything was impossible to being relatively competent in the space of a few short weeks. I was very impressed with it.
Apple's documentation is amazingly good, but it takes a while to get used to the style, and you will need to know which objects actually exist before you can look up how to use them, which is where Aaron's book comes in.
Your library may have a copy of it, or be able to order one for you if they don't.
I think you mean windows, not screens. Screens are the displays (monitors) on which all the user's windows from all the user's applications appear.
And I second Jonathan's recommendation of the Hillegass book.
The button has a target. That should link to the new window. As its action you can tell the window to show itself.
Take a look at:
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/WinPanel/WinPanel.html
I think what you want is the type of interface like that seen in Coda, or System Preferences where there is a toolbar on the top of the screen that can be used to select between the content of the window.
The simplest method I have found is to use BWToolkit.
Another method is to use a series of views, and switch between them when the toolbar is clicked. I've found one description here, but that's not the one I used first (which may have been originally in Ruby Cocoa, IIRC).
NSTabView.