How to Track

Hi All,

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?

Thanks,

Hi Infop,

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.

Hope this helps.

ROCLASI:
I don’t know if this works but see if the onShow form-event triggers when you switch windows.

Hi Robert,

Thanks for your quick response. No, the onShow form-event is not triggering, while switching windows.
Any work around?

Hi Infop,

Infop:
Any work around?

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.

Hope this helps.

Thanks Robert,

I will try using window listener and will also create a feature request.

Thanks,

Hi Infop,

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.

TESTS.servoy (4.22 KB)

ptalbot:
It’s quite easy really, the only trick it to get a handle of the Dialog to attach your listener to.

Thanks a lot Patrick, It is really amazing :D .