Пример #1
0
	def _handle_key_press(self, widget, event):
		"""
		Handle key presses from the keyboard and translate key combinations into actions.
		This key press handler is called prior to the gtk key press handler.
		This handler bypasses built in accelerator key handling when in focus because
		* some keys are ignored by the accelerators like the direction keys,
		* some keys are not registered to any accelerators but are still used.
		When not in focus, gtk and the accelerators handle the the key press.
		@return false to let gtk handle the key action
		"""
		#dont allow key presses to queue up
		if gtk.events_pending(): return True
		#extract action name from this key press
		key_name = gtk.gdk.keyval_name(event.keyval)
		mod_mask = event.state
		action_name = Actions.get_action_name_from_key_name(key_name, mod_mask)
		#handle the action if flow graph is in focus
		if action_name and self.get_focus_flag():
			self.handle_states(action_name)
			return True #handled by this method
		return False #let gtk handle the key press