本文整理汇总了Python中AppKit.NSApplication.sendEvent_方法的典型用法代码示例。如果您正苦于以下问题:Python NSApplication.sendEvent_方法的具体用法?Python NSApplication.sendEvent_怎么用?Python NSApplication.sendEvent_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppKit.NSApplication
的用法示例。
在下文中一共展示了NSApplication.sendEvent_方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ns_process_key_event
# 需要导入模块: from AppKit import NSApplication [as 别名]
# 或者: from AppKit.NSApplication import sendEvent_ [as 别名]
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)
示例2: sendEvent_
# 需要导入模块: from AppKit import NSApplication [as 别名]
# 或者: from AppKit.NSApplication import sendEvent_ [as 别名]
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)