Is there a way to know when a webpart gets focused? I've look around, but couldn't find anything helpful.
I had to do something similar recently when trying to hide the ribbon in SP 2010. I have a blog article about it here: http://www.thelineberrys.com/default-category/option-to-show-the-sharepoint-2010-ribbon-when-hidden-by-default-2.html
I can tell you the function
get's called when you click on a webpart. I had found another function when an item is selected but I don't remember what it was because the OnRibbonMinimizedChanged was the one I needed to tap into.
I hope this helps get you down the path you need. Thanks.