示例#1
0
 def keyDown_(self, event) -> None:
     # any time this table is in focus and a key is pressed, this method will be called
     if toga_key(event) == {'key': Key.A, 'modifiers': {Key.MOD_1}}:
         if self.interface.multiple_select:
             self.selectAll(self)
     else:
         # forward call to super
         send_super(__class__, self, 'keyDown:', event)
示例#2
0
    def textDidEndEditing_(self, textObject) -> None:
        # Cocoa gives and then immediately revokes focus when the widget
        # is first displayed. Set a local attribute on the first *loss*
        # of focus, and only trigger Toga events when that attribute exists.
        if hasattr(self, '_configured'):
            if self.interface.on_lose_focus:
                self.interface.on_lose_focus(self.interface)
        else:
            self._configured = True

        send_super(__class__, self, 'textDidEndEditing:', textObject)
示例#3
0
 def becomeFirstResponder(self) -> bool:
     # Cocoa gives and then immediately revokes focus when the widget
     # is first displayed. Set a local attribute on the first *loss*
     # of focus, and only trigger Toga events when that attribute exists.
     if hasattr(self, '_configured'):
         if self.interface.on_gain_focus:
             self.interface.on_gain_focus(self.interface)
     return send_super(__class__, self, 'becomeFirstResponder')
示例#4
0
    def createContentView(self):
        superClipView = ObjCInstance(send_super(__class__, self,
                                                'contentView'))
        if not isinstance(superClipView, RefreshableClipView):
            # create new clipview
            documentView = superClipView.documentView
            clipView = RefreshableClipView.alloc().initWithFrame(
                superClipView.frame)

            clipView.documentView = documentView
            clipView.copiesOnScroll = False
            clipView.drawsBackground = False

            self.setContentView(clipView)
            superClipView = ObjCInstance(
                send_super(__class__, self, 'contentView'))

        return superClipView
示例#5
0
    def documentRect(self) -> NSRect:
        rect = send_super(__class__,
                          self,
                          'documentRect',
                          restype=NSRect,
                          argtypes=[])

        if self.superview and self.superview.refreshTriggered:
            return NSMakeRect(
                rect.origin.x,
                rect.origin.y - self.superview.refreshView.frame.size.height,
                rect.size.width, rect.size.height +
                self.superview.refreshView.frame.size.height)
        return rect
示例#6
0
    def constrainScrollPoint_(self, proposedNewOrigin: NSPoint) -> NSPoint:
        constrained = send_super(__class__,
                                 self,
                                 'constrainScrollPoint:',
                                 proposedNewOrigin,
                                 restype=NSPoint,
                                 argtypes=[NSPoint])

        if self.superview and self.superview.refreshTriggered:
            return NSMakePoint(
                constrained.x,
                max(proposedNewOrigin.y,
                    -self.superview.refreshView.frame.size.height))

        return constrained
示例#7
0
    def scrollWheel_(self, event) -> None:
        if event.phase == NSEventPhaseEnded:
            if self.refreshTriggered and not self.isRefreshing:
                self.reload()

        send_super(__class__, self, 'scrollWheel:', event)
示例#8
0
文件: cells.py 项目: yconst/toga
 def init(self):
     self = ObjCInstance(send_super(__class__, self, 'init'))
     return self.setup()
示例#9
0
文件: cells.py 项目: yconst/toga
 def initWithFrame_(self, frame: CGRect):
     self = ObjCInstance(send_super(__class__, self, 'initWithFrame:', frame))
     return self.setup()