def __init__(self, sheet): Edit.__init__(self, "", 100, self.onEnter) self.setShow(0) self.row=0 self.col=0 self.sheet = sheet self.registerEvent(pyui2.locals.KEYDOWN, self.onKeyDown)
def onKeyDown(self, event): if event.key == pyui2.locals.K_DOWN: if self.row >= self.sheet.visibleRows-1: return 0 self.onEnter(None,0) self.activateAt(self.col, self.row+1) return 1 if event.key == pyui2.locals.K_UP: if self.row <= 1: return 0 self.onEnter(None,0) self.activateAt(self.col, self.row-1) return 1 if event.key == pyui2.locals.K_LEFT: if self.col <= 1: return 0 self.onEnter(None,0) self.activateAt(self.col-1, self.row) return 1 if event.key == pyui2.locals.K_RIGHT: if self.col >= self.sheet.visibleColumns-1: return 0 self.onEnter(None,0) self.activateAt(self.col+1, self.row) return 1 return Edit._pyui2KeyDown(self, event)
def loseFocus(self): self.handler(self, 0) return Edit.loseFocus(self)