Ticket #625 (closed defect: moved)

Opened 8 years ago

Last modified 7 years ago

Hotkey problems in IJ2

Reported by: bdezonia Owned by: curtis
Priority: major Milestone: imagej-2.5.0
Component: Plugin Framework Version:
Severity: serious Keywords:
Cc: Blocked By:


The hotkey accelerators are not completely working. As an example take the Next Axis Position and Previous Axis Position plugins. Ideally their hotkeys would be defined as GREATER and LESS and yet since they're shifted keys IJ2 can't handle it. I can fake it via setting hotkey to shift COMMA and shift PERIOD but they display poorly in the menus. This issue also affects the zoom plugins (shift EQUALS rather than PLUS).

Change History

comment:1 Changed 8 years ago by bdezonia

This is a Java issue that is still unfixed. See  http://stackoverflow.com/questions/5870685/java-swing-key-event-base for a discussion of the issue. Their workaround is the same as ours.

Wayne gets around this in IJ1 by defining ImageJ.java to be a KeyListener. It listens for the actual typing (event.getKeyChar()) of ">" and launches plugin directly. This might be his workaround to the problem. We may need to do something similar.

comment:2 Changed 8 years ago by gharris

  • Owner changed from bdezonia to gharris
  • Status changed from new to assigned
  • Milestone changed from imagej-2.0-beta2 to imagej-2.0-alpha5

comment:3 Changed 8 years ago by gharris

One approach... Add an EventSubscriber for KeyEvents and invoke the functionality there.

comment:4 Changed 7 years ago by gharris

This a now addressed with AWTKeyEventDispatcherGlobal, although there are still some focus-related issues. Specifically, the accelerator keys defined in the menus are not responsive if the focus is not on the ApplicationFrame (at least in Windows).

comment:5 Changed 7 years ago by bdezonia

On the Mac the accelerator keys are responsive whether you've selected the app bar or the image window. Testing with ">" and "<" on multidim images works correctly even when multiple images are open (moving only the sliders of the last active window).

Note this ticket has the unaddressed problem (at least on the Mac) that the accelerators for ">" and "<" show in the menus as "shift ." and "shift ,". Grant, not sure if you meant to address that part too.

comment:6 Changed 7 years ago by curtis

I believe this problem can be fixed by making the AcceleratorHandler smarter about detecting this sort of situation. If you type e.g. shift+PERIOD to get a GREATER, the event that fires has a code of PERIOD (not GREATER) with the shift modifier set. (Run the "Watch Events" plugin and give it a try.) However, the character is a '>' which means that we can potentially invoke special handling for the situation.

Once the AcceleratorHandler is smart enough to realize that shift+PERIOD should fire a command with an accelerator of GREATER on U.S. keyboards (based on analysis of the character), it won't matter that the Swing menu infrastructure ignores the key event—the AcceleratorHandler will fire the command anyway.

However, to make this work, we may need to provide a way to inquire what the given KeyCode is for a char, and vice versa.

Further investigation needed.

comment:7 Changed 7 years ago by curtis

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [4482]) Change displayed shortcuts for axis pos plugins

Closes #625. It does not fully solve the issue of modifiers affecting a
key code (they still don't), nor does it make AcceleratorHandler smarter
in general, but in the case of the axis position plugins displaying <
and > accelerators in the menu, those keys *do* work now because
the AxisPositionHandler picks them up.

comment:8 Changed 7 years ago by curtis

(In [4493]) Add always-active ZoomHandler to handle +/- keys

This is instead of letting the ZoomIn and ZoomOut accelerators function,
since ZoomIn was mapped to ctrl/meta + equals, which was kind of hacky.
See #625 for details.

comment:9 Changed 7 years ago by curtis

  • Status changed from closed to reopened
  • Resolution fixed deleted

On second thought, I am reopening this ticket but pushing it to a later milestone, now that we have resolved the problem for the axis position and zoom plugin cases. It would still be good to implement a more general solution that is smart about mapping modified keys to their respective key codes.

comment:10 Changed 7 years ago by curtis

  • Milestone changed from imagej-2.0-beta1 to imagej-2.5

comment:11 Changed 7 years ago by curtis

  • Owner changed from gharris to curtis

comment:10 Changed 5 years ago by curtis

  • Status changed from reopened to closed
  • Resolution set to moved
Note: See TracTickets for help on using tickets.