def eventFilter(self, obj, event):
if obj == self._text_edit:<EOL><INDENT>etype = event.type()<EOL>if etype == QtCore.QEvent.KeyPress:<EOL><INDENT>key = event.key()<EOL>if self._consecutive_tab == <NUM_LIT:0> and key in (QtCore.Qt.Key_Tab,):<EOL><INDENT>return False<EOL><DEDENT>elif self._consecutive_tab == <NUM_LIT:1> and key in (QtCore.Qt.Key_Tab,):<EOL><INDENT>self._consecutive_tab = self._consecutive_tab+<NUM_LIT:1><EOL>self._update_list()<EOL>return True<EOL><DEDENT>elif self._consecutive_tab == <NUM_LIT:2>:<EOL><INDENT>if key in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter):<EOL><INDENT>self._complete_current()<EOL>return True<EOL><DEDENT>if key in (QtCore.Qt.Key_Tab,):<EOL><INDENT>self.select_right()<EOL>self._update_list()<EOL>return True<EOL><DEDENT>elif key in ( QtCore.Qt.Key_Down,):<EOL><INDENT>self.select_down()<EOL>self._update_list()<EOL>return True<EOL><DEDENT>elif key in (QtCore.Qt.Key_Right,):<EOL><INDENT>self.select_right()<EOL>self._update_list()<EOL>return True<EOL><DEDENT>elif key in ( QtCore.Qt.Key_Up,):<EOL><INDENT>self.select_up()<EOL>self._update_list()<EOL>return True<EOL><DEDENT>elif key in ( QtCore.Qt.Key_Left,):<EOL><INDENT>self.select_left()<EOL>self._update_list()<EOL>return True<EOL><DEDENT>elif key in ( QtCore.Qt.Key_Escape,):<EOL><INDENT>self.cancel_completion()<EOL>return True<EOL><DEDENT>else :<EOL><INDENT>self.cancel_completion()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.cancel_completion()<EOL><DEDENT><DEDENT>elif etype == QtCore.QEvent.FocusOut:<EOL><INDENT>self.cancel_completion()<EOL><DEDENT><DEDENT>return super(CompletionHtml, self).eventFilter(obj, event)<EOL>
Reimplemented to handle keyboard input and to auto-hide when the
            text edit loses focus.