def ns_process_key_event(self, ns_event): # Perform menu setup before command-key events. # Send non-command key events to associated window if any, # otherwise pass them to the pygui application. This is necessary # because otherwise there is no way of receiving key events when # there are no windows. if ns_event.modifierFlags() & NSCommandKeyMask: NSApplication.sendEvent_(self._ns_app, ns_event) else: ns_window = ns_event.window() if ns_window: ns_window.sendEvent_(ns_event) else: event = Event(ns_event) self.handle(event.kind, event)
def sendEvent_(self, ns_event): # Perform special processing of key events. # Perform menu setup when menu bar is clicked. # Remember the most recent mouse-moved event to use as the # location of event types which do not have a location themselves. if Globals.pending_exception: raise_pending_exception() ns_type = ns_event.type() self.pygui_app._ns_menus_updated = False if (1 << ns_type) & _ns_key_event_mask: self.pygui_app.ns_process_key_event(ns_event) else: if ns_type == NSMouseMoved: Globals.ns_last_mouse_moved_event = ns_event ns_window = ns_event.window() if ns_window: ns_view = ns_window.contentView().hitTest_(ns_event.locationInWindow()) if ns_view: ns_view.mouseMoved_(ns_event) else: NSApplication.sendEvent_(self, ns_event)