imagej / imagej2

Open scientific N-dimensional image processing :microscope: :sparkler:
https://imagej.net/
BSD 2-Clause "Simplified" License
1.2k stars 337 forks source link

Press L to focus to search bar on Channels window #307

Closed hyungsongnam closed 2 years ago

hyungsongnam commented 2 years ago

Hello, I apologize if this is not the correct forum for this, but here goes. I just noticed that the "press L to focus to search bar" behavior is inconsistent across different windows. For example, I have the main window, Channels and W&L set up to open at startup. It appears as though the "press L to focus" doesn't seem to work when the Channels windows is in the foreground. Please see attached movie. What I'm doing in the movie is clicking a window then pressing L to focus to search bar. My set up is macOS 12.3.1, Oracle Java 8 331, ImageJ 1.53q99. Could I ask if this could be easy to "fix?" It's somewhat annoying, and it doesn't seem like a complex problem that may be difficult to address. Thank you. Sincerely, Hyung-song Nam, PhD

https://user-images.githubusercontent.com/36607862/164162136-3be80ee5-589c-44fe-bd65-2ebff931070f.mov

ctrueden commented 2 years ago

Thank you for the report. I agree it is annoying. Unfortunately, I do not have time to look into it any time soon. It is not a simple issue; the shortcut handling of ImageJ is convoluted. Notice that not only does L not work, but other shortcuts like O (to open a file) also do not work—at least on macOS they don't. And command+O does not work from the Channels dialog either, even though the Mac menu bar flashes. If you select it via the mouse though, then it works.

Furthermore, it might require extending the ImageJ patcher to include a new hook that lets us inject more behavior into objects of type ij.plugin.frame.PlugInFrame. I'm not sure which behavior yet, though. I tried to tweak an open Channels window manually using this script:

#@ EventService eventService

import org.scijava.ui.awt.AWTInputEventDispatcher

// Grab ImageJ's Channels window. It must be open for this to work.
channelsWindow = ij.WindowManager.getWindow("Channels")

// Hook up the SciJava input handler to the window.
if (channelsWindow) new AWTInputEventDispatcher(null, eventService).register(channelsWindow, true, true)

But unfortunately it didn't work. That is: bringing the Channels window into focus and then pressing L did not trigger the Focus Search Bar plugin.

Assuming someone else digs into this, and is able to get it working, note also that we should probably be mapping all the AWT events for ImageJ 1.x windows to SciJava events, not only input events—there are window events and drag-and-drop events, too.

hyungsongnam commented 2 years ago

Thank you for the reply. Understood. I'll just work around it. I will leave this open. Thank you. Sincerely, Hyung-song Nam, PhD

ctrueden commented 2 years ago

@hyungsongnam I played around a little more, and discovered some interesting things:

Maybe the tab + L workaround is good enough for you for now?

And perhaps @rasband would be interested to make the L key (for the command finder) work from the Channels dialog when the combo box is selected? It might be enough to add a key listener to the dropdown list box, I'm not sure.

hyungsongnam commented 2 years ago

Sure, I can definitely work around it. Thanks for looking into it.

So I'm not imagining it or it happens only on my computer or something like that. But if it would take a lot of work to overhaul to fix, there would be other priorities, etc.

i got to thinking about why this was bothering me in the first place, and it was because the Channels windows was selected after I open an image.

It looks like the default for Channels has 3 channels. My images now usually have 4 channels. So, when I open an image, the image is opened, and the Channels window is automatically selected, and it is updated from 3 to 4 channels. Then, the focus remains on the Channels window.

Another "fix" might be to change this behavior, i.e., after updating the Channels window, the Channels window returns the focus to the main image window. But since I'm aware of this now, I can certainly work around it by clicking on the main image window once before typing L, takes one second.

Thank you.

Sincerely, Hyung-song Nam, PhD

rasband commented 2 years ago

The ImageJ 1.53r22 daily build adds a key listener to the drop down menu in the Channels window, which seems to fix this problem.

ctrueden commented 2 years ago

@rasband Thank you!

@hyungsongnam wrote:

I can certainly work around it by clicking on the main image window once before typing L, takes one second.

In case you didn't know: you can press enter to bring the main window back into focus, rather than clicking it. However, before the fix in 1.53r22, it had the same problem as pressing L directly: the dropdown list box ate the key press. But now with the fix, both enter and L work with the Channels window freshly opened! 🎊