Assign keystroke to menu command

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Assign keystroke to menu command

Knecht, David
The documentation says that to assign a keystroke to a menu command to use the Plugins/Create Shortcut.  However, most menu commands do not show up in the list.  Is there a way of assigning shortcuts to menu commands (I am trying to do Image/3D Project)?  I also tried it by creating a macro.  The macro works from the menu command but not from the keystroke I assigned as a shortcut.  I also found no way of altering the shortcut keystroke.  When I went back in to Shortcut, the keystroke I previously added did not show.  Do you have to remove and add, or is it just not showing what was added?  Should the keystroke show up somewhere so you can easily look up what you assigned to what?    Dave

Dr. David Knecht    
Department of Molecular and Cell Biology
Co-head Flow Cytometry and Confocal Microscopy Facility
U-3125
91 N. Eagleville Rd.
University of Connecticut
Storrs, CT 06269
860-486-2200
860-486-4331 (fax)
Reply | Threaded
Open this post in threaded view
|

Re: Assign keystroke to menu command

Tiago Ferreira-2
On 2010.03.14, at 12:18 , David Knecht charter wrote:
>The documentation says that to assign a keystroke to a menu command to
>use the Plugins/Create Shortcut.  However, most menu commands do not
>show up in the list.  

 I cannot reproduce this. Note that the list is not ordered by alphabetic
 order (Maybe that's what you are referring to?)

>Is there a way of assigning shortcuts to menu commands (I am trying to do
>Image/3D Project)?  I also tried it by creating a macro.
>The macro works from the menu command but not from the keystroke I assigned
>as a shortcut.  

 The documentation also says:
 "A macro can be assigned a keyboard shortcut by listing the shortcut in brackets
  after the macro name. Note that keyboard shortcuts will not work unless the
  macros are installed and the ImageJ window, or an image window, is the active
  (front) window and has keyboard focus. [examples given]"

 So, once installed, the following macro will run when you press F1:
   //
    macro "3DProj [F1]"{run("3D Project...");}
   //

>I also found no way of altering the shortcut keystroke.  When I went back in to
>Shortcut, the keystroke. I previously added did not show.  
>Do you have to remove and add, or is it just not showing what was added?
>Should the keystroke show up somewhere so you can easily look up what you
>assigned to what?

 The command with the assigned shortcut will be listed under 'Plugins>Shortcuts'.
 So, e.g to assign the shortcut '6' to the above command you would run:
   //
   run("Create Shortcut... ", "command=[3D Project...] shortcut=6");
  //

Running Plugins>Utilities>List Shortcuts ,or in a macro:
   //
   run("List Shortcuts...");
   //
 You will see the new shortcut preceded by an asterisk.

 Note also that you can use Plugins>Find Commands [L], to easily reach a command
 without the need of assigning keyboard shortcuts. Pressing 'L' then typing '3D '
 carriage return will take you there easily.
 This is also written on the documentation.