CHyperAlert is almost a direct clone of AppKit’s NSAlert class. The primary difference is that instead of passing plain old strings, you can pass it HTML which will get rendered with WebKit inside the alert. This way you can have clickable URLs inside your alert dialogs. Hell, you can get really fancy and put Flash or QuickTime movies inside your dialogs. Why would you want to do this? The same reason men climb mountains: because they can. And because they’re probably adrenaline junkies who like to risk their lives in freezing, oxygen poor environments where one mistake can kill you.
Fortunately no one has ever died using one of my Cocoa classes (although tying yourself to your partner is definitely recommended).
The API of CHyperAlert is identical to NSAlert and its behaviour is almost identical. The dialog will stretch and grow based on its content. Buttons will get assigned shortcut keys as per NSAlert, and so on. There are two extra methods for passing HTML formated and DOM nodes (representing the body of the HTML document) to the class. Also if passed a plain string it will try to convert URLs to full clickable anchors. Clicked anchors will use NSWorkspace to open the URL in the default URL handler (probably a Web Browser but who knows)
The code users some neat Carbon Icon family code from Daniel Jalkut. Thanks Daniel.
Links:
Before: plain, old dull NSAlert.
After: dynamic, trendy, popular with the ladies CHyperAlert.
Add New Comment
Viewing 2 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment