not shure, but try to look into;

http://www.conitec.net/beta/on_message.htm

on_message functions,
there you should be able to grab the unfocus event