So … I think I have an idea how to do this, but thought it would be good to see if anyone disagrees or has a better method.
I have a nice system for midilearn, where individual components register as a changeListener with the top level component - which is in turn registered with the midi managing component to receive all incoming midi messages. So incoming messages get disseminated via the high level window to all relevant UI elements as change messages. Pretty standard I guess.
I want to do the same for KeyPresses … so I register individual components, dynamically mapping various keys per user inputs to components … I use the convenient addShortcut() - which registers the UI elements as listeners with the top level window.
The problem is that in the first case (midi) I have just one midiManager that broadcasts all appropriate messages to the high level component … but in the case of keys, the KeyPressed() method is only executed on the currently focused component, and not necessarily passed on … so if my high level window doesn’t have the focus, the KeyPress is sometimes recieved and stamped out by the currently focused component.
I don’t want to constantly force the focus to the high level window, as this causes some issues …
So I am guessing that the way around this is to override the KeyPressed() method in custom classes, making sure the method returns false and passes the Key on up to the parent, which can then dispense a message.
Naturally, I don’t really want to do this if there is an easier way … and further, I am wondering about, say, modal dialogs … where I’m not sure I can override the KeyPressed method … ?
Anyway, thought I might have missed something simple here, so I figured I’d check before diving in.
Thanks
A
