def keyPressEvent(self, event): key = event.key() if platformSpecific.isDeleteEvent(event): glyph = self._glyph # TODO: fuse more the two methods, they're similar and delete is # Cut except not putting in the clipboard if event.modifiers() & Qt.AltModifier: deleteUISelection(glyph) else: preserveShape = not event.modifiers() & Qt.ShiftModifier # TODO: prune glyph.prepareUndo() removeUIGlyphElements(glyph, preserveShape) elif key in arrowKeys: # TODO: prune self._glyph.prepareUndo() dx, dy = self._moveForEvent(event) # TODO: seems weird that glyph.selection and selected don't incl. # anchors and components while glyph.move does... see what glyphs # does moveUIGlyphElements(self._glyph, dx, dy) elif key in navKeys: pack = self._getSelectedCandidatePoint() if pack is not None: point, contour = pack point.selected = False index = contour.index(point) offset = int(key == Qt.Key_Greater) or -1 newPoint = contour.getPoint(index + offset) newPoint.selected = True contour.postNotification( notification="Contour.SelectionChanged")
def keyPressEvent(self, event): key = event.key() if platformSpecific.isDeleteEvent(event): indexes = self.selectedIndexes() if indexes: data = self.model().data(indexes[0]) self.groupDeleted.emit(data) elif key == Qt.Key_Left: self.alignmentChanged.emit(False) elif key == Qt.Key_Right: self.alignmentChanged.emit(True) else: super().keyPressEvent(event)
def keyPressEvent(self, event): modifiers = event.modifiers() if platformSpecific.isDeleteEvent(event): erase = modifiers & Qt.ShiftModifier if self._proceedWithDeletion(erase): glyphs = self.glyphsForIndexes(self._selection) for glyph in glyphs: font = glyph.font if erase: del font[glyph.name] else: # TODO: consider doing that in glyph template setter glyph.clear() glyph.template = True elif event.matches(QKeySequence.SelectAll): self.selectAll() elif event.key() == Qt.Key_D and modifiers & Qt.ControlModifier: self.setSelection(set()) else: super().keyPressEvent(event)