PDA

View Full Version : Checking whether app has focus


shdon
05-20-2010, 04:34 AM
Is there any way to detect whether the OL app I'm creating actually has the systemwide input focus? I want to play a quick sound effect for event notifications when the user is currently working in another browser tab or application, but when the user is actually working in the app, the event notifications are obvious enough and don't need sound.

I think Flash does this with the Stage.focus property, but I'm not entirely sure, nor on how it translates to OL.

Can anybody advise?

kmeixner
06-04-2010, 11:28 AM
Is there any way to detect whether the OL app I'm creating actually has the systemwide input focus? I want to play a quick sound effect for event notifications when the user is currently working in another browser tab or application, but when the user is actually working in the app, the event notifications are obvious enough and don't need sound.

I think Flash does this with the Stage.focus property, but I'm not entirely sure, nor on how it translates to OL.

Can anybody advise?

Hi,

I am not sure but maybe you can have a JavaScript function outside of the OpenLaszlo application that checks if the object with focus is your OpenLaszlo application by checking if the object with focus matches an id on your <object> tab (IE) or id on your <embed> tag (Most other browsers) that your OpenLaszlo application is embedded with?

I think it might be easier to do this entirely outside of OpenLaszlo working entirely with JavaScript otherwise you will have to deal with the complications of having to setup your OpenLaszlo application to call an external JavaScript function which is kind of a pain to do. Also, if you did it in OpenLaszlo you'd probably have to have a polling function on a timer to constantly call the external function to see if the application has focus or not which would not be a good design.

Kev