I have two forms(form-1 & form-2) showing in two non-modal dialogs. User can switch in between them. How can I track the switching. Let’s say, I want to show different menus for form-1 and form-2. So, I need to track the switching so that i will be able to change the menus. Is it Doable? or any work around?
I don’t know if this works but see if the onShow form-event triggers when you switch windows.
If not then I think you need to file a feature request for a onFocus/onFocusLost form-event.
The only workaround I can think of is to do some Java and use a window Listener. Perhaps Jeff Bader (jbader) or Patrick Talbot (ptalbot) can help you with that.
You will find below a little example of how to use a WindowFocusListener, how to implement it and how to attach it to a form in a window. That should help you doing exactly what you need.
It’s quite easy really, the only trick it to get a handle of the Dialog to attach your listener to.
So I used a little workaround: putting a simple bean on the form (in the non visible part of the form) and iterating in the “onShow” event (the first time it is triggered) to get the “Dialog” parent of that bean (Forms in window are not java.awt.Frames instances but java.awt.Dialog instances).
Once you got a reference of the Dialog, attach a java listener, with a form (or global) callback function which will be triggered each time depending of the listener method implemented…
It could be done better with a plugin, and I have in mind something that will handle attaching any listeners to any Servoy objects (depending on their type). If anyone is interested, drop me a line.
NOTE: The example is based on the “example_data” source, so make sure you have it in you database servers before importing.