0 Replies Latest reply on Jul 13, 2010 2:17 AM by Osaka Andrew

    Capturing keyboard events in new NativeWindow (AJAX)

    Osaka Andrew

      I've tried searching everywhere and I can't find anything useful. I am unable to figure out how to access keyboard events in a window I've created from my main application window. I can listen for keyboard events in my main window, no problem, but any child window (created with StageDisplayState.FULL_SCREEN_INTERACTIVE) refuses to acknowledge keyboard events.

       

      I am spawning the windows like this:

       

      var wWindow = new air.NativeWindow(objWindowOptions);
      wWindow.activate();

       

      wWindow.stage.displayState = window.runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
      wWindow.stage.scaleMode = "noScale";
      wWindow.stage.addChild( htmlView );
      htmlView.load( new air.URLRequest("newpage.html") );

       

      I've tried binding an event listener using all combinations of the following:

       

      var handler = function() {
          alert('success!');
      };
      var strEventName = KeyboardEvent.KEY_DOWN; // Fails -- is undefined
      //var strEventName = KeyboardEvent.KEYDOWN; // Fails -- is undefined
      //var strEventName = 'keydown'; // Fails
      // var strEventName = 1024; // Fails

      window.nativeWindow.stage.addEventListener(strEventName,handler,false); // Fails
      nativeApplication.addEventListener(strEventName,handler,false); // Fails
      window.addEventListener(strEventName,handler,false); // Fails

       

      Again, I have no problem with creating an event listener on the main window, it's just the child windows that are failing to bind.

       

      Any idea what I'm doing wrong?