Java Swing Keyboard Events
Submitted by Sunday, 14 March, 2004 - 03:35
on
I'm in the middle of developing a plugin to provide EditPane switching like the Alt-Tab behavior on Windows and Macs. The idea is that although jEdit allows you to switch to the *next* EditPane, what you really want to do is switch to the last active EditPanes.
Windows lets you hold down Alt and hit Tab repeatedly to cycle through all the windows (in a circular linked list). When you find the one you want, you let go Alt. The newly-active window gets removed from the linked list and gets placed on the head. That means that you're able to switch very quickly between recently used windows with relatively little effort.
I've been trying to emulate this behavior, and since this kind of keyboard manipulation goes beyond the simple keyboard shortcuts, I've been trying to handle these events through the KeyListener interface, using the View.setKeyEventInterceptor() function to grab events. However, I'm noticing that I'm never receiving KEY_PRESSED events, only KEY_RELEASED and KEY_TYPED events. And even when I receive the KEY_RELEASED events, I'm never getting the KEY_RELEASED events for modifier keys like Ctrl or Alt.
Does anyone know if there's anything that jEdit does to keyboard events that might make this act weird? Or is this pretty standard behavior in Swing apps?
Windows lets you hold down Alt and hit Tab repeatedly to cycle through all the windows (in a circular linked list). When you find the one you want, you let go Alt. The newly-active window gets removed from the linked list and gets placed on the head. That means that you're able to switch very quickly between recently used windows with relatively little effort.
I've been trying to emulate this behavior, and since this kind of keyboard manipulation goes beyond the simple keyboard shortcuts, I've been trying to handle these events through the KeyListener interface, using the View.setKeyEventInterceptor() function to grab events. However, I'm noticing that I'm never receiving KEY_PRESSED events, only KEY_RELEASED and KEY_TYPED events. And even when I receive the KEY_RELEASED events, I'm never getting the KEY_RELEASED events for modifier keys like Ctrl or Alt.
Does anyone know if there's anything that jEdit does to keyboard events that might make this act weird? Or is this pretty standard behavior in Swing apps?