本文整理汇总了Python中AppKit.NSEvent.addGlobalMonitorForEventsMatchingMask_handler_方法的典型用法代码示例。如果您正苦于以下问题:Python NSEvent.addGlobalMonitorForEventsMatchingMask_handler_方法的具体用法?Python NSEvent.addGlobalMonitorForEventsMatchingMask_handler_怎么用?Python NSEvent.addGlobalMonitorForEventsMatchingMask_handler_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppKit.NSEvent
的用法示例。
在下文中一共展示了NSEvent.addGlobalMonitorForEventsMatchingMask_handler_方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install_global_handler
# 需要导入模块: from AppKit import NSEvent [as 别名]
# 或者: from AppKit.NSEvent import addGlobalMonitorForEventsMatchingMask_handler_ [as 别名]
def install_global_handler(_id, handler, event_mask, key_mask=None):
def key_handler(ev):
if (ev.modifierFlags() & NSDeviceIndependentModifierFlagsMask) == key_mask:
handler(ev)
def simple_handler(ev):
handler(ev)
if not _id:
_id = str(handler) + str(event_mask) + str(key_mask)
obs = NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(
event_mask, key_handler if key_mask else simple_handler)
GLOBAL_HANDLERS[_id] = obs
示例2: show_popover
# 需要导入模块: from AppKit import NSEvent [as 别名]
# 或者: from AppKit.NSEvent import addGlobalMonitorForEventsMatchingMask_handler_ [as 别名]
def show_popover(self):
self.on_show_callback()
bounds = self.button.bounds()
print 'BOUNDS ', bounds
print 'show popover'
#NSWindow *window = [[[NSApplication sharedApplication] currentEvent] window];
window = NSApplication.sharedApplication().currentEvent().window()
x = NSApplication.sharedApplication().currentEvent().window().frame().origin.x
y = NSApplication.sharedApplication().currentEvent().window().frame().origin.y
x = x - 300
if x < 0:
x = 0
y = y - 20
point = NSPoint(x, y)
#point.setX_(x)
#point.setY_(y)
self.window.setFrameOrigin_(point)
from Cocoa import NSApp as CocoaNSApp
CocoaNSApp.activateIgnoringOtherApps_(True)
#NSApp.activateIgnoringOtherApps_(True)
self.window.makeKeyAndOrderFront_(self.window)
#NSApplication.sharedApplication().activateIgnoringOtherApps(True)
self._shown = True
#self.popover.showRelativeToRect_ofView_preferredEdge_(
# self.button.bounds(),
# self.button,
# NSMinYEdge
#)
def global_click(evt):
print 'Global click!'
self.close_popover()
self.monitor = NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(
NSLeftMouseDownMask | NSRightMouseDownMask,
global_click
)
示例3: _observe
# 需要导入模块: from AppKit import NSEvent [as 别名]
# 或者: from AppKit.NSEvent import addGlobalMonitorForEventsMatchingMask_handler_ [as 别名]
def _observe(self):
# Must be called after root.mainloop() so that the app's message loop has been created
self.observer = NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSKeyDownMask, self._handler)