Keyboard shortcuts

edited July 2013 in General
HI,
Is it possible to create keyboard shortcuts? for example for the edit>selection>subtraction?
If so ,how do i do it?
Thanks
shirly

Comments

  • edited July 2013

    Hi Shirly,

    yes it is. File->Setup, page Application/Key Bindings. Choose the item for which you want to install a shortcut, enter the desired key into the shortcut box right to the item list and hit "Ok".

    Matthias

  • "Key Bindings" no longer exists as of 2023, using version 0.28.7

    what is the new location?

  • Hi nmz787_intel
    In newer version, the kotkey can be set in customiz menu tab

  • ... and it is called "Customize Menu" now since you can turn off menu entries :)

  • I have a question about key-bindings. Maybe two.

    • Can a key be bound to a "macro"?
    • Can a key be bound to a chain of singlet commands, short of
      "macro-izing", by some syntax (like command;command )?

    I also recall there was a particular binding which was "hard"
    while others were "soft" (user can change). Don't remember
    which, why or why I cared at one point. My question (#3)
    there is, is that still so or is everything up for grabs.

    OK, #4 - is there a facility for saving out and reading back
    (onstartup, by klayoutrc?) a customized bindkey definition
    file?

  • Hi dick_freebird

    macro can be bind to hot key throuth macro properties setting page (wrench icon).
    key bind can be set at default key short cut option

    For change hot key binding using a script that bind to a hot key,
    here's an example of saving hot key and load back

    import pya
    import pickle
    
    def saveCurrentKeyBind(fileFullPath):    
        with open(fileFullPath, 'wb') as f:
            mainWindow  = pya.Application.instance().main_window().instance()    
            keyBindDict = mainWindow.get_key_bindings()
            pickle.dump(keyBindDict, f)
    
    def loadKeyBind(fileFullPath):
        with open(fileFullPath, 'rb') as f:
            mainWindow  = pya.Application.instance().main_window().instance()    
            keyBindDict = pickle.load(f)
            mainWindow.set_key_bindings(f)
    
    saveCurrentKeyBind("current_keybind.pickle")
    loadKeyBind("current_keybind.pickle")
    
  • Exactly :) Thanks @RawrRanger!

    Matthias

  • Hi Matthias, the "Customize Menu" tool is an awesome feature. Is there an option for switching the type of ruler? Ideally I could assign a different shortcut/hotkey for Ruler, Cross, Box, etc.

  • edited December 2023

    HI 14darcia,

    Ruler and annotation currently does not have a shortcut setting avaliable in the customize menu page,

    but we can always acess the menu items by macro and bind the macro to a hotkey like my previous comment.

    For example we use edit_menu.mode_menu.ruler.ruler_template_{i} to set current ruler type (Ruler, Box, measure..., I starts from 1 to customized ruler template counts)

    After set and template, call with @toolbar.ruler to trigger measure function.

    In following example, the 2nd ruler template is setted as active ruler, in my case is a diagnal measurement, it'll not always be the same accross different machine.

    Paset following codes and change the 2 number in last line and bind the macro to keys, repeat this until you got all the template/key~~~~ set.

    def activateRuler(i = 1):
        menu = pya.Application.instance().main_window().instance().menu()
        menu.action(f"edit_menu.mode_menu.ruler.ruler_template_{i}").trigger()
        menu.action("@toolbar.ruler").trigger()
    
    activateRuler(2) 
    #             ^
    # change this number and bind the script to different hot key
    # repeat this to map keys to different ruler type
    
  • Very good, thanks @RawRanger!

    Instead of triggering a specific action, you can also use the canonical ways - i.e. "set_config" and "switch_mode". This may be a slightly more portable:

    def activateRuler(i = 1):
      pya.MainWindow.instance().set_config("current-ruler-template", str(i))
      pya.LayoutView.current().switch_mode("ruler")
    

    Best regards,

    Matthias

Sign In or Register to comment.