Hotkey Assignment Returns False

   597   0   0
User Avatar
Member
13 posts
Joined: July 2013
Offline
Hi,

A have a question about hotkey assignment. I simply want to assign a hotkey to an existing shelf tool with the python line above.
Generally It returns False and seems like that the hotkey symbol is missing. If I go to the Hotkey Editor and set it manually and clear right after that the same python line works. So my question is can I update, create the hotkey symbol or define, assign it to an existing shelf tool command ?

hou.hotkeys.addAssignment('h.tool:display_viewer_1','Pad1')


I checked in Houdini built in module where the editor runs but I did not find any other hou.hotkey method what is used.
    def _addkey_action_accept(self, key, commandItem=None):
        if key is None and self.addKeyWidget is not None:
            key = self.addKeyWidget.text()
        if commandItem is None:
            commandItem = self._getCurrentCommandItem()
        if commandItem is not None:
            result = hou.hotkeys.addAssignment(commandItem.symbol, key)
            if not result:
                self._addkey_action_changed(key, commandItem)
            else:
                self._setKeysChanged(True)
                # update the list...
                currentCommandItem = self._getCurrentCommandItem()
                currentCommandItem.keys = \
                    hou.hotkeys.assignments(currentCommandItem.symbol)
                self._updateKeylist(currentCommandItem.keys)
                self._update_assignment_window(self.full_conflict_window)
                self._updateVirtualKeyboard(currentCommandItem.symbol,
                                            currentCommandItem.keys)
                for index in self.commands.selectionModel().selectedIndexes():
                    self.commands.update(index)
Edited by Gemini4147 - June 14, 2023 04:48:46
  • Quick Links