How to add a badge to your app's dock icon...

I believe progress bars are done from pre-generated images of the icon with bars, so you’d just be temporarily setting the icon to another image.

I don’t know, sounds like it. I know this method of NSDockTile will do the trick:

- (void)setContentView:(NSView *)view

So I guess I’ll have to create an NSView in IB and then assign it with this method to the dock’s icon and tell it to display itself. I can’t do any testing yet, but for sure i’m gonna try it! Too exciting!

Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)

Hello,

what do I need to get your example to work?
My AppleScript returns the error: “NSApp doesn’t understand the dockTile message.”
Thanks.

Regards,
Delivery Boy

Model: MacBook Pro
AppleScript: 2.2.1
Browser: Safari 534.57.2
Operating System: Mac OS X (10.7)

Nothing special. Works just fine in any ASOC application. The trick it to call NSApp (which is just the short version of NSApplication). NSapp is your application, currently running. So you’re telling it to get its dock icon, then set a badge onto it. As far as I know, this is part of appkit, so there’s no need to import any framework or libraries.

Which version of Xcode are you working on?

So was I. Objective-C says just:

Anywhere in the code. Objective-C, I’m crazy about you :slight_smile:

Same here! Furiously in love with objective-c now! All thanks to applescriptobjc!

Soooo much better… And the speed! The speed! I still use ASOC when I need to talk to other apps, but recently I found how to use scripting bridge in objc. There’s a tool that converts the AppleScript dictionary of an app (sdef) and creates a .h file with it. Genius! So I think that in the not too far future it’ll be bye bye AppleScript… Our love was good, but I found better :slight_smile:

For me, ApplescriptObjC is the first stage of the Objective-C rocket. I would never have a takeoff without it.

I think this “bridge” is a brilliant idea: you come from Applescript, you enter the ASOC door to Cocoa, and you start learning the framework without noticing it, translating them into your loved Applescript syntax. And after a year, tired to coerce your variables, you find yourself programming in a language you would never dare to deal with.

The second stage is, of course, this forum. It is cleverly built, and you get fast answers from very skilled people. Have a look on other Objective-C sites and you will know what I’m talking about.

I suggest you hunt around a bit. Genius is definitely not the word most used to describe it…

I meant for the tool to convert the sdef file… I haven’t started playing around with it, i’ll start with simple tasks and medium-sized apps like Numbers before attacking bigger ones like InDesign.

But at least, that’s a start. I had nothing before, so I consider this great, been looking for awhile… :slight_smile:

Oh, and besides these forums, I find Stack Overflow to be of nice help, most questions I have have beeen answered in one form or another in the past (mostly because of my beginner level limitations :wink: ), and people are usually quite friendly… usually.

You might want to start here: cocoadev.com/wiki/ScriptingBridgeCriticisms

Hi,

is it possible to have an example of the applescript?
If I execute, it dosn’t appear the badge number on the applescript editor icon.

What code did you try?

I tried this:

on setDockBadgeString_("9")
	set appDockTile to current application's NSApp's dockTile()
	appDockTile's setBadgeLabel_("9")
end setDockBadgeString_

Should it add a [9] badge on the Applescript Editor app icon?

I’m a noob in AppleScript…

Look at post #1, there is is two parts to this. There’s a method that you put somewhere in your code then you call this method with the second part.

Btw, this is applescriptobjc, not plain AppleScript. Thus your project needs to be done under Xcode or Shane’s app, AppleScript explorer if I remember correctly.

Is it Applescript Studio?
Basically I want to add the badge icon to the FileMaker Icon in the dock.
maybe this post can help you to help me? :stuck_out_tongue:
http://macscripter.net/viewtopic.php?id=36605

Nope, this is not AppleScript Studio. AppleScript Studio has been deprecated when OS X Snow Leopard came out a few years ago. It’s replacement is AppleScriptObjC, which is completely different, but a huge improvement.

And sorry, but you can’t add a badge to another app (as far as I know). This code is for your own app while it’s running, and will not work the way you want it to. Sorry.

neither if FileMaker can run applescript itself?

This is what I’ve been saying. This is not plain AppleScript. In your case, if there is no AppleScript command built into the application to set it’s dock badge icon, then there is no other way to do it. I’ve never seen it before, not would I know how to do it. I could be wrong, but one thing is for sure, you cannot do it with AppleScript, and neither with AppleScriptObjC, unless in this case the app talks to itself, not other apps.

Ok, thank you