当前位置: 首页>>代码示例>>Python>>正文


Python NSEvent.addGlobalMonitorForEventsMatchingMask_handler_方法代码示例

本文整理汇总了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
开发者ID:JulianEberius,项目名称:qsx,代码行数:15,代码来源:hotkeys.py

示例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
        )
开发者ID:pfitzsimmons,项目名称:rumps,代码行数:45,代码来源:rumps.py

示例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)
开发者ID:GankisKhan,项目名称:EDMarketConnector,代码行数:5,代码来源:hotkey.py


注:本文中的AppKit.NSEvent.addGlobalMonitorForEventsMatchingMask_handler_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。