toxicsoftware.com

RANDOMIZE USR 0

toxicsoftware.com header image 2

Are you feeling a little Hyper Alert?

May 19th, 2006 · Comments · Default

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.

Subversion Repository

Demo Application

Tags:

  • Wow! This looks great! I see the project is set to use the 10.4u SDK. Is there any reason why this wouldn't run with the 10.3.9 SDK?

    Thanks,

    Jeremy
  • Glad you like it.

    There is a private API method call used that may or may not be supported in < 10.4 - look in WebView_Private.h - I think it might have been added to WebKit to support transparent backgrounds for Dashboard Widgets. I can't think of anything else that might limit CHyperAlert to 10.4 though.
blog comments powered by Disqus