Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4089468

JDK115C REGRESSION: no focus events are generated when tabbing 2 lw components

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1
    • Resolution: Fixed
    • Affects Version/s: 1.1.5
    • Fix Version/s: 1.1.5
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.1.5
    • CPU:
      x86
    • OS:
      windows_95, windows_nt
    • Verification:
      Verified

      Description


      ingrid.yao@Eng 1997-10-29

      Apply Oracle suggested fix for bug 4070597 partially cause the worse
      focus problem. Specifically, *no* focus events are generated when tabbing
      between two lightweight components that are traversable by using the tab key.
      Previously, the focus was correctly switched between the two components using
      the tab key; the original bug prevented requesting the focus while in the
      middle of handling a focus gain.

          boolean setFocusRequest(Component c) {
              boolean peerNeedsRequest = true;
              Window w = nativeContainer.getWindow();
              if (w != null && c != null) {
                  Component focusOwner = w.getFocusOwner();
                  if (focusOwner == nativeContainer) {
                      // This container already has focus, so just
                      // send FOCUS_GAINED event to lightweight component
                      focus = c ;
                      c.dispatchEvent(new FocusEvent(c, FocusEvent.FOCUS_GAINED, false
      ));
                      peerNeedsRequest = false;
                  } else if (focusOwner == c) {
                      // lightweight already has the focus
                      focus = c ;
                      peerNeedsRequest = false;
                  } else if (focusOwner == focus) {
                      // a lightweight component has focus currently and a new one has
       been
                      // requested. There won't be any window-system events associate
      d with
                      // this so we go ahead and send FOCUS_LOST for the old and FOCUS
      _GAINED
                      // for the new.
                      if (focus != null) {
                          focus.dispatchEvent(new FocusEvent(focus,
                                                             FocusEvent.FOCUS_LOST,
                                                             false));
                          focus = c ;
                          c.dispatchEvent(new FocusEvent(c, FocusEvent.FOCUS_GAINED, f
      alse));
                          peerNeedsRequest = false;
                      }
                  }
              }
              focus = c; <======************ Should take this line out
              return peerNeedsRequest;
          }

      I have verify that after taking out "focus =c;" line, the problem will
      go away.

      ========================================================================
      On a window that has a mixture of lightweight and
      heavyweight components.

      First bring focus to a lightweight component (by
      mouse click or TAB key).

      Then bring focus to either a heavyweight component
      or another lightweight with a different heavyweight
      parent.

      Then mouse click(not TAB) on a lightweight component on the
      same container as the lightweight that had focus in
      the first step.

      Result:
      The lightweight that first had focus gets the
      focus gained instead of the component clicked on.


      Cause:
      LightweightDispatcher.setFocusRequest is allowing
      execution to exit the if(focusOwner==nativeContainer)
      block without setting the foucs variable to
      the component requesting focus.

      boolean setFocusRequest(Component c) {
          boolean peerNeedsRequest = true;
          Window w = nativeContainer.getWindow();
          if (w != null && c != null) {
              Component focusOwner = w.getFocusOwner();
              if (focusOwner == nativeContainer) {
      // This container already has focus, so just
      // send FOCUS_GAINED event to lightweight component
      focus = c ;
      c.dispatchEvent(new FocusEvent(c, FocusEvent.FOCUS_GAINED, false));
      peerNeedsRequest = false;
              } else if (focusOwner == c) {
      // lightweight already has the focus
      focus = c ;
      peerNeedsRequest = false;
              } else if (focusOwner == focus) {
        // a lightweight component has focus currently and a new one has been
      // requested. There won't be any window-system events associated with
      // this so we go ahead and send FOCUS_LOST for the old and FOCUS_GAINED
      // for the new.
      if (focus != null) {
      focus.dispatchEvent(new FocusEvent(focus,
      FocusEvent.FOCUS_LOST,
      false));
                  }
      focus = c ;
      c.dispatchEvent(new FocusEvent(c, FocusEvent.FOCUS_GAINED, false));
      peerNeedsRequest = false;
      }
      //add fix here
              else {
                  //keep ref to component so it recieves events can be redirected to it when this container recieves focus.
                  focus=c
      //end fix
          }
          return peerNeedsRequest;
      }

        Attachments

          Activity

            People

            Assignee:
            duke J. Duke (Inactive)
            Reporter:
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: