3 Replies Latest reply on Mar 28, 2008 9:48 AM by Applied CD

    Issues with WebXtra and window/keyboard focus

    Applied CD Level 1
      I’ve got a form built in Director with editable text fields and a print button. A WebXtra sprite is offstage in the same frame. When the user hits print an HTML template is read into a string and tokens in the template are replaced with data from the editable text fields, the string is then passed to WebXtra (offstage) and printed. The reason for printing this way is that HTML gives me far better formatting control over the printed output than I can achieve with PrintOMatic.

      Here’s the problem: WebXtra appears to steal the window and/or keyboard focus when its sprite is initialized. If the user navigates to the form and just starts typing nothing happens because as far as I can tell the stage and its sprites do not have keyboard focus. Clicking anywhere on the stage restores focus and everything behaves normally but that extra click shouldn’t be necessary. I’ve tried forcing keyboard focus to the first text sprite everywhere and it doesn’t seem to help. I’ve also tried baActivate(baWinHandle()) to force focus to the stage and that doesn’t work either. The only thing that does work is to type _moive.keyboardFocusSprite = 93 (the first text sprite) into the message window and suddenly everything is back to normal.

      For now I’ve got a low tech work around. I’ve got the WebXtra sprite stretched through the entire movie. The simple act of clicking to navigate to the forms is sufficient to make sure the stage has keyboard focus when the editable sprites are reached, however, this feels like a kluge, it seems like there should be a more definitive method for restoring focus to the stage.

      Related Question: Does anyone know a way to programmatically suppress the header and footers on a printed web page? I know the user can delete them from the page setup dialog but I haven’t found a way to print my HTML forms without those unsightly headers automatically.
        • 1. Re: Issues with WebXtra and window/keyboard focus
          Level 7
          Applied CD wrote:
          > Here?s the problem: WebXtra appears to steal the window and/or
          > keyboard focus when its sprite is initialized. If the user navigates
          > to the form and just starts typing nothing happens because as far as
          > I can tell the stage and its sprites do not have keyboard focus.
          > Clicking anywhere on the stage restores focus and everything behaves
          > normally but that extra click shouldn?t be necessary. I?ve tried
          > forcing keyboard focus to the first text sprite everywhere

          How?

          > and it
          > doesn?t seem to help. I?ve also tried baActivate(baWinHandle()) to
          > force focus to the stage and that doesn?t work either. The only thing
          > that does work is to type _moive.keyboardFocusSprite = 93 (the first
          > text sprite) into the message window and suddenly everything is back
          > to normal.

          Assuming the WebXtra sprite is in a lower-numbered channel than the sprite
          you want focused on, can't you just use

          property spriteNum
          on beginSprite
          the keyboardFocusSprite=spriteNum
          end

          on the first text member sprite?

          If that's how you meant isn't working, then perhaps you need to delay
          setting the focus, either by counting a couple of frames in an enterFrame
          handler, or by using a timeOut object.

          Andrew


          • 2. Re: Issues with WebXtra and window/keyboard focus
            Mouseclick Multimedia Level 1
            The way you solved it is actually the way I solved it too, I never figured out a way to get it to work another way...
            • 3. Re: Issues with WebXtra and window/keyboard focus
              Applied CD Level 1
              I tried putting _movie.keyboardFocusSprite=<spriteNum of 1st text field> in a number of different locations: in the beginSprite handler for the first text field (as in your example), in the beginSprite handler for the webxtra sprite, in exitFrame and enterFrame handlers one frame after all sprites have been initialized, and as tests (these tests will would disable all text input except the first field): in the exitFrame loop holding the play head on the frame and on both the exitFrame and enterFrame handlers of the webxtra sprite itself. None of these work, and it doesn’t seem to matter whether the WebXtra sprite channel is higher or lower than the text fields (although logically it would be better to initialize webxtra first (lower channel)). I didn’t try the timeout script, however, the last two tests I described should be constantly issuing a change of focus to the first text sprite so I don’t see how timing could be an issue.

              I’m not sure but I think once the webxtra sprite initializes keyboard focus is passed to the browser window in the sprite and is no longer under Director control until a mouse click on the stage brings it back.