Skip to content

DevFaqTweakRegistryByCodeReplacement

Antonio Vieiro edited this page Jan 25, 2018 · 1 revision

DevFaqTweakRegistryByCodeReplacement

How do I have only shortcut keys for an action?

The New Action wizard allows you to uncheck both menu and toolbar placement for your action and only assign a keyboard shortcut. To learn how to do this manually, read on. Refer to TaT_HackingNetBeansXMLLayerPartOne for more details.

Trick #1

  • Retain the action’s basic registration:

<folder name="Actions">
    <folder name="Tools">
        <file name="org-nvarun-tat-SayCheez.instance"/>
    </folder>
</folder>
  • This registers an action as a Global Menu Item:

<folder name="Menu">
    <folder name="Tools">
        <file name="org-nvarun-tat-SayCheez.shadow">
            <attr name="originalFile"
                  stringvalue="Actions/Tools/org-nvarun-tat-SayCheez.instance"/>
            <attr name="position" intvalue="150"/>
        </file>
    </folder>
</folder>
  • This registers an action as a Global Toolbar Button:

<folder name="Toolbars">
    <folder name="Build">
        <file name="org-nvarun-tat-SayCheez.shadow">
            <attr name="originalFile"
                  stringvalue="Actions/Tools/org-nvarun-tat-SayCheez.instance"/>
            <attr name="position" intvalue="325"/>
        </file>
    </folder>
</folder>
  • To assign a shortcut key, replace either or both of them with something like the following:

<folder name="Shortcuts">
    <file name="O-F3.shadow">
        <attr name="originalFile"
              stringvalue="Actions/Tools/org-nvarun-tat-SayCheez.instance"/>
    </file>
</folder>

Trick #2

  • In the above example the action has the shortcut key Alt+F3, which is represented as O-F3. In general, if you have some key combination that uses Alt (or the equivalent on Mac OS X), then use O. Separate modifiers from the base keycode name with -, and append .shadow for the filename. Ctrl (or its Mac equivalent) is represented by D, and Shift*by S. (C and A represent the literal *Ctrl and Alt keys, but this is less portable.)

Tips to Remember

  1. Following are some keycode equivalents. See Javadoc for KeyEvent for the full list:

    • A to Z (as is), F1 to F12 (as is), 0 to 9 (as is)

    • / as SLASH, \ as BACK_SLASH

    • ; as SEMI_COLON

    • . as PERIOD

    • as QUOTE

See also DevFaqKeybindings.

(Reposted from this entry on NetBeans Zone.)

Apache Migration Information

The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.

This page was exported from http://wiki.netbeans.org/DevFaqTweakRegistryByCodeReplacement , that was last modified by NetBeans user Jtulach on 2010-07-24T20:39:23Z.

NOTE: This document was automatically converted to the AsciiDoc format on 2018-01-26, and needs to be reviewed.

Clone this wiki locally