0 Replies Latest reply: Nov 28, 2008 11:58 PM by 843851 RSS

    Do not get key events when HContainer object is added to HScene

    843851
      Experts,

      Please help, I am missing something simple.

      I am creating an container (mCurrentContainer) with some buttons in them as follows,
                mRecListButton = new HTextButton("List", curX, curY);
                add(mRecListButton);
                
                // Setup a recording
                curY += V3Button.mHeight + gap;
                mRecButton = new HTextButton("Record", curX , curY);
                add(mRecButton);
                
                // Shows the list of scheduled recordings
                curY += V3Button.mHeight + gap;
                mScheduleRecButton = new HTextButton("Schedule", curX , curY);
                add(mScheduleRecButton);
                
                // Shows the list of Series Recordings
                curY += V3Button.mHeight + gap;
                mSeriesRecButton = new HTextButton("Series", curX, curY);
                add(mSeriesRecButton);
                
                mCurrentSelectedButton = LISTVALUE;
                
                mRecListButton.setFocus();

      Then I am creating a scene,
                HSceneFactory factory = HSceneFactory.getInstance();
                HSceneTemplate sceneTemplate = new HSceneTemplate();

                sceneTemplate.setPreference(HSceneTemplate.
                               SCENE_PIXEL_DIMENSION,
                               new Dimension(640, 400),
                               HSceneTemplate.REQUIRED);

                sceneTemplate.setPreference(HSceneTemplate.
                               SCENE_SCREEN_LOCATION,
                               new HScreenPoint((float)0,(float)0),
                               HSceneTemplate.REQUIRED);

                mScene = factory.getBestScene(sceneTemplate);
                mScene.requestFocus();
                mScene.addFocusListener(this);

      Then, I add the above container to the mscene as follows,
      mCurrentContainer = myContainer;
      mScene.add(mCurrentContainer); // Keys Presses do not work if left uncommented
      mScene.setVisible(true);
      mScene.requestFocus();
      mScene.addKeyListener( mCurrentContainer);
      mCurrentContainer.setVisible(true);
      mCurrentContainer.requestFocus();

      I see the buttons correctly and the "List" button is highlighted correctly. However, I do not get any key presses.

      Now, if I comment out "mScene.add()" as follows,
      mCurrentContainer = myContainer;
      // mScene.add(mCurrentContainer); // Now the key presses works correctly.
      mScene.setVisible(true);
      mScene.requestFocus();
      mScene.addKeyListener( mCurrentContainer);
      mCurrentContainer.setVisible(true);
      mCurrentContainer.requestFocus();

      The key presses works correctly. However, the buttons are not displayed now.

      What am I missing?

      Thanks!