Anonymous avatar Anonymous committed ab795d5

Added keyboard based selection of the items and added the shortcut to the toolTip.

Comments (0)

Files changed (1)

+#: The keys for accessing pyrad element via the keyboard
+SELECTION_KEYS_ORDERED = "0123456789abcdefghijklmnopqrstuvwxyz"
 ### Window ###
 class ItemEditWidget(QWidget):
                 # If pyRad didn't reach a final action, we stop here.
                 if event.button() == Qt.LeftButton:
                     if self.labelClicked(i) is None:
-                        break
+                        break # TODO: Check if we can use return None instead
                 elif event.button() == Qt.RightButton and i !=[0]:
                 # Otherwise we can hide the pyRad
+    def keyReleaseEvent(self, event):
+        """Select items via keyboard."""
+        # Debug: Don't react, if an edit dialog is open.
+        if self.editor.main.isVisible():
+            return None
+        key = str(event.text())
+        if key and key in SELECTION_KEYS_ORDERED[:len(]:
+            idx = SELECTION_KEYS_ORDERED.index(key)
+            if not self.labelClicked([idx]) is None:
+                self.hide()
     def addLabelAfter(self, label): # -> open message box -> set item.icon and item.action. -> save_config()
         """Edit a label. A click on the center item promts for adding a new label."""
         # add a new label.
         circle = []
         for icon, action in items:
             label = self.item_to_label(icon, action)
+            # we set the tooltip here,
+            # because it needs the position in the circle.
+            if SELECTION_KEYS_ORDERED[len(circle):]: 
+                key = SELECTION_KEYS_ORDERED[len(circle)]
+                toolTip =  key + " - " + str(action)
+            else:
+                toolTip = str(action)
+            label.setToolTip(toolTip)
         return circle
         label = QLabel(self)
         label.icon = icon
         label.action = action
-        label.setToolTip(str(action))
+        # The tooltip must be set outside this function,
+        # because it needs the position in te circle. 
+        # label.setToolTip(str(action))
         label.setPixmap(self.iconloader.loadIcon(icon, 0))
         return label
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.