minor bug fix to gainFocus/ loseFocus events