diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 105989c7715d47af4c9cda6ae7bd7faee6b4b54a..3eb38c7eb71b653f07d7378004a1ce7e2d8c31ae 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -465,7 +465,7 @@ class MainWindow(QMainWindow): 'Ctrl+Z', "undo", getStr("undo"), enabled=False) change_cls = action(getStr("keyChange"), self.change_box_key, - 'Ctrl+B', "undo", getStr("keyChange"), enabled=False) + 'Ctrl+B', "edit", getStr("keyChange"), enabled=False) lock = action(getStr("lockBox"), self.lockSelectedShape, None, "lock", getStr("lockBoxDetail"), @@ -980,6 +980,9 @@ class MainWindow(QMainWindow): self.labelList.scrollToItem(self.currentItem()) # QAbstractItemView.EnsureVisible self.BoxList.scrollToItem(self.currentBox()) + if len(self.canvas.selectedShapes) == 1 and self.keyList.count() > 0: + selected_key_item_row = self.keyList.findItemsByLabel(self.canvas.selectedShapes[0].key_cls, get_row=True) + self.keyList.setCurrentRow(selected_key_item_row) self._noSelectionSlot = False n_selected = len(selected_shapes) diff --git a/PPOCRLabel/libs/unique_label_qlist_widget.py b/PPOCRLabel/libs/unique_label_qlist_widget.py index 785647f8942321825e04ca0affa8b8cbd81a82bd..f1eff7a172d3fecf9c18579ccead5f62ba65ecd5 100644 --- a/PPOCRLabel/libs/unique_label_qlist_widget.py +++ b/PPOCRLabel/libs/unique_label_qlist_widget.py @@ -17,12 +17,14 @@ class UniqueLabelQListWidget(EscapableQListWidget): if not self.indexAt(event.pos()).isValid(): self.clearSelection() - def findItemsByLabel(self, label): + def findItemsByLabel(self, label, get_row=False): items = [] for row in range(self.count()): item = self.item(row) if item.data(Qt.UserRole) == label: items.append(item) + if get_row: + return row return items def createItemFromLabel(self, label):