How to prevent DF from eating up key events?

I’m using DF (v1.1.1) as part of a bigger application where it is possible to branch from and to various sub applications. When branching, the origin sub app remains in memory in order to be able to restore it easily when coming back from the branch. One of those sub apps is realized with use of DF. When branching from this sub app to another one, key events won’t be recognized unless there is no dockable focused. The key events obviously are eaten up by some key listener provided by DF.

I tried different approaches to come around this point, i.e. setting all dockables to invisible or even removing them from the control. Nothing worked. My plan to ‘unfocus’ the currently focused dockable failed due to absence of an appropriate method.

Any idea to come around this???

A small and poor demo app based on DF-1.1.1 can be downloaded here:

https://docs.google.com/open?id=0BzdKc1NQwWCEcjg5b0lnN3QxQlk

At the upper right corner of the demo app you see a branch button. When pressing it, the body panel switches to a second one that reports recognized key events by setting the text of a label. Works fine in case of you didn’t focus any of the two dockable on the first panel. Otherwise, i.e. a dockable is focused on the first panel, nothing is reported.

Would the method “CControl.addGlobalKeyListener” help? It should report all those KeyEvents that are catched by the framework.

Otherwise I’ll have to dig in the code, I do no longer remember what exactly the framework does with KeyEvents…

I don’t know how to go on with the global key listener! Just seeing which events are processed by the framework - where shall that lead to?

I guess another aproach could lead to success. I mentioned that the problem only occurs if a dockable is focused prior to branch. And I recognized that if a dockable is focused prior to branch, it is always unfocused when coming back. This seems to be intended by the framework which means there must be a way to unfocus a dockable. Now the question for me is: How to unfocus a dockable programmatically before branching? I tried

CControl.getController().setFocusedDockable(…)

in all variants in order to do this (the method allows null values). The method seems not to do anything. Is this a bug or do I interpret the purpose of this method wrong?

Sorry for the long delay, I was not around at the weekend.

Swing does not really allow to remove the focus (at least I do not know how to do that), as a result calling „setFocusedDockable“ with „null“ does not do anything. The Dockables may no longer have the focus when you switch windows because the focus was an another window.

I don’t know how to go on with the global key listener! Just seeing which events are processed by the framework - where shall that lead to?

I did not say „processed“, I did say „catched“. This means also the KeyEvents which did not start any action.

The framework either

  • adds a KeyListener to any Component if in „restricted mode“ (Applet or Webstart)
  • adds an AWTEventListener to the Toolkit if in „normal mode“ (Application).
    I do not know what your application exactly does, but all I can offer is this global KeyListener. It should give you all the events you missed. Or is there a reason why you cannot use the KeyListener?