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)
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)
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')
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
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
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
def scrollWheel_(self, event) -> None: if event.phase == NSEventPhaseEnded: if self.refreshTriggered and not self.isRefreshing: self.reload() send_super(__class__, self, 'scrollWheel:', event)
def init(self): self = ObjCInstance(send_super(__class__, self, 'init')) return self.setup()
def initWithFrame_(self, frame: CGRect): self = ObjCInstance(send_super(__class__, self, 'initWithFrame:', frame)) return self.setup()