Dock menu items and window focus

15 views
Skip to first unread message

Toby Sterrett

unread,
Mar 15, 2008, 2:22:56 AM3/15/08
to fluidapp
Hey, first off I just want to say Fluid is awesome. I've known of it
for a while but only the other day stumbled across all the cool stuff
you can do with Javascript and now I'm a true believer. I added a
bunch of those features to my web app (http://stafftool.com) like dock
menu items and a message count badge and it works great. I wrote up a
blog post about it if you're curious - http://stafftool.com/blog/2008/03/09/stafftool-app/

Anyways, one thing I noticed was that choosing a menu item from the
dock menu works great, but doesn't give the app focus. So, for
instance, I have menu items for creating new records in the app, but
if you're not currently in the app (or on a different space) the event
fires and works, but you remain wherever you are. Would it be possible
to give the app focus, like if you choose "Compose new message" from
Mail's dock menu?

Thanks again for the great app.

todd.dit...@gmail.com

unread,
Mar 15, 2008, 3:13:29 PM3/15/08
to fluidapp
Thanks Toby, glad you found Fluid useful! Cool article too. I'll link
to it in the next link batch.

Re: activating the app on dock menu click... that would actually be
easy to do... trying to think if this is always the right thing to do
or not... anyone else have any input? I'll try a bunch of other apps
now and see what they do...

todd

todd.dit...@gmail.com

unread,
Mar 15, 2008, 3:51:06 PM3/15/08
to fluidapp
I just had an idea...

window.fluid.activate();

Makes a system request to "activate" your SSB. "Activate" is the
keyword in cocoa for bringing an application to the front. This way
you can choose to activate the app for your menu item or not. Notice
that some apps activate when you click a dock menu item and some dont.
for example, itunes does not activate when yo click a menu item. but
mail does.

i've just added this to the build and i think it's cool...

todd

Jed Hurt

unread,
Mar 15, 2008, 3:55:56 PM3/15/08
to flui...@googlegroups.com
That sounds like a good solution. 

Mickaël Menu

unread,
Mar 18, 2008, 3:38:06 PM3/18/08
to fluidapp
Yes, very good idea!
And we can use this function for other things. :)

Todd Ditchendorf

unread,
Mar 18, 2008, 3:44:50 PM3/18/08
to flui...@googlegroups.com
BTW, I've implemented this (as well as .hide(), .unhide(), and .terminate()) in the upcoming 0.8.6. These methods are only available to Userscripts however, so random websites will *not* be able to quit your SSB.

I had hopped to get 0.8.6 out last weekend, but it now looks like i'm going to wait until this weekend to get the Plug-In API a little more solid. Stay tuned!

Toby Sterrett

unread,
Mar 19, 2008, 12:25:09 AM3/19/08
to fluidapp
This is awesome Todd, great solution :) Looking forward to 0.8.6, the
plugin stuff looks killer.

On Mar 18, 12:44 pm, "Todd Ditchendorf" <todd.ditchend...@gmail.com>
wrote:

timcharper

unread,
Apr 10, 2008, 3:36:30 AM4/10/08
to fluidapp
Hi Todd,

This is awesome. I've been wanting to make the campfire growl script
activate when you click a growl notification (similar to how IM's
work).

I can't seem to get any of the .hide, .unhide, .activate commands to
work though (I'm using 0.8.8). Is it possible that I've broken
something? Is there an example script somewhere ?

thanks!

Tim

On Mar 18, 1:44 pm, "Todd Ditchendorf" <todd.ditchend...@gmail.com>
wrote:
Message has been deleted

todd.dit...@gmail.com

unread,
Apr 10, 2008, 3:46:28 AM4/10/08
to fluidapp
hi tim, thanks for taking a look at the userscript stuff...
unfortunately the issue you mentioned is a known bug. In 0.8.6, i
added the concept of 'privileged' JS API... a few methods of the
window.fluid object that may *only* be called from local userscripts
(cuz you wouldn't want random websites calling them).

as i said, there is an issue. it turns out that with the way i
implemented this, those privileged methods may only be called when the
Userscript is initially parsed/evaled. they may not be called in
callback functions later (like a growl click callback) even if they
originate from a userscript. obviously i would like to fix this, i
just have to find time! I'll let you know.

as for the callback itself... i would try something simpler in your
onclick callback till you are confident you have it working.

todd
Reply all
Reply to author
Forward
0 new messages