Beispiel #1
0
	def onKeyDown(self, event):
		if html5.isReturn(event):  # Return
			self.activateCurrentSelection()
			event.preventDefault()
			return
		elif html5.isControl(event):  # and "multi" in (self.selectMode or ""): #Ctrl
			self._isCtlPressed = True
Beispiel #2
0
    def onKeyUp(self, event):
        if html5.isControl(event):
            self._isCtlPressed = False
            self._ctlStartRow = None

        elif html5.isShift(event):
            self._isShiftPressed = False
            self._ctlStartRow = None
Beispiel #3
0
    def onKeyUp(self, event):
        if html5.isControl(event):
            self._isCtlPressed = False
            self._ctlStartRow = None

            # leave selection mode if there is only one row selected and return to normal focus
            if len(self._selectedRows) == 1:
                for row in self.getCurrentSelection():
                    self.removeSelectedRow(row)

        elif html5.isShift(event):
            self._isShiftPressed = False
            self._ctlStartRow = None
Beispiel #4
0
    def onKeyDown(self, event):
        if html5.isArrowDown(event):  # Arrow down

            if self._currentRow is None:
                self.setCursorRow(0)

            else:
                if self._isCtlPressed or self._isShiftPressed:

                    if self._ctlStartRow > self._currentRow:
                        self.removeSelectedRow(self._currentRow)
                    else:
                        self.addSelectedRow(self._currentRow)

                        if self._currentRow + 1 < self.getRowCount():
                            self.addSelectedRow(self._currentRow + 1)

                if self._currentRow + 1 < self.getRowCount():
                    self.setCursorRow(
                        self._currentRow + 1,
                        removeExistingSelection=(not self._isShiftPressed
                                                 and not self._isCtlPressed))

            event.preventDefault()

        elif html5.isArrowUp(event):  # Arrow up

            if self._currentRow is None:
                self.setCursorRow(0)
            else:

                if self._isCtlPressed or self._isShiftPressed:  # Check if we extend a selection
                    if self._ctlStartRow < self._currentRow:
                        self.removeSelectedRow(self._currentRow)
                    else:
                        self.addSelectedRow(self._currentRow)

                        if self._currentRow > 0:
                            self.addSelectedRow(self._currentRow - 1)

                if self._currentRow > 0:  # Move the cursor if possible
                    self.setCursorRow(
                        self._currentRow - 1,
                        removeExistingSelection=(not self._isShiftPressed
                                                 and not self._isCtlPressed))

            event.preventDefault()

        elif html5.isReturn(event):  # Return

            if len(self._selectedRows) > 0:
                self.selectionActivatedEvent.fire(self, self._selectedRows)
                event.preventDefault()
                return

            if self._currentRow is not None:
                self.selectionActivatedEvent.fire(self, [self._currentRow])
                event.preventDefault()
                return

        elif html5.isControl(event):  # Ctrl
            self._isCtlPressed = True
            self._ctlStartRow = self._currentRow or 0
            if self._currentRow is not None:
                self.addSelectedRow(
                    self._currentRow)  # add already selected row to selection

        elif html5.isShift(event):  # Shift
            self._isShiftPressed = True
            try:
                self._ctlStartRow = self._currentRow or self._selectedRows[
                    0] or 0
            except:
                self._ctlStartRow = 0
Beispiel #5
0
 def onKeyUp(self, event):
     if html5.isControl(event):
         self._isCtlPressed = False