I converted an objective-c example to ASOC that demonstrated how to add a badge to your dock icon. Thought it might be useful to someone. Here is the code:
on setDockBadgeString_(dockBadgeString)
set appDockTile to current application's NSApp's dockTile()
appDockTile's setBadgeLabel_(dockBadgeString)
end setDockBadgeString_
You simply call it like this from your code:
my setDockBadgeString_("9999")
Documentation says to pass a string. Didn’t try with an integer or float yet, could work. Also, if you want to remove the badge, call the routine again by passing “” or missing value.
Enjoy!
P.S.: I’m madly in love with AppleScriptObjC!
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)
Ain’t it! It’s awesome indeed… and so easy! Eventually I want to figure out how to add things like progress bars or other elements over the dock icon. I’ll post my successes on these forums of course…
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)
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)
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.
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
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 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…
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 ), and people are usually quite friendly… usually.
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? 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.