locked
determine when silverlight plug-in loses/gets focus RRS feed

  • Question

  • Is there any way to know when the plug in does not have the browser's focus? I noticed that even if you click outside of the plug-in, the same element still has the silverlight focus.

     example: we have an override on the browser's right click event that pops up a custom context menu. When clicking a certain function in the menu, I need to know whether a certain field in the plug-in has focus, or if this function is being invoked from outside of the plug-in.

    Tuesday, November 10, 2009 2:09 PM

Answers

  • Hi,

       Yes , you will need javascript.

       Here is my thought.  You can write some logic in your document.body.onclick event.  Inside it you can invoke some managed code to manipulate your focuse.

      In your asp.net page put this:

    <script>
       document.body.onclick = funciton(){
           //do your stuff
       }
    </script>
    Best Regards
     
    Friday, November 13, 2009 3:01 AM

All replies

  • I suppose, you can solve your problem via javascript events
    Tuesday, November 10, 2009 6:18 PM
  • Hi,

       Yes , you will need javascript.

       Here is my thought.  You can write some logic in your document.body.onclick event.  Inside it you can invoke some managed code to manipulate your focuse.

      In your asp.net page put this:

    <script>
       document.body.onclick = funciton(){
           //do your stuff
       }
    </script>
    Best Regards
     
    Friday, November 13, 2009 3:01 AM
  • Thanks, I actually found different solution to my problem -- when the oncontextmenu event is fired, one of the event args is srcElement; I used this to determine if the event was happening over the silverlight plug-in. Thank you for providing this solution though.

    Friday, November 13, 2009 8:16 AM