Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 365396
Collapse All | Expand All

(-)js/qx/ui/core/Widget.js (+3 lines)
Lines 3201-3206 Link Here
3201
          this.removeState("abandoned");
3201
          this.removeState("abandoned");
3202
          this.removeState("pressed");
3202
          this.removeState("pressed");
3203
        }
3203
        }
3204
        if( this.getFocused() ) {
3205
          this.setFocused( false );
3206
        }
3204
      } else {
3207
      } else {
3205
        this.removeState("disabled");
3208
        this.removeState("disabled");
3206
      }
3209
      }
(-)src/org/eclipse/swt/widgets/Control.java (-1 / +9 lines)
Lines 329-346 Link Here
329
  public void setEnabled( boolean enabled ) {
329
  public void setEnabled( boolean enabled ) {
330
    checkWidget();
330
    checkWidget();
331
    /*
331
    /*
332
     * TODO [rst] handle focus
333
     * Feature in Windows.  If the receiver has focus, disabling
332
     * Feature in Windows.  If the receiver has focus, disabling
334
     * the receiver causes no window to have focus.  The fix is
333
     * the receiver causes no window to have focus.  The fix is
335
     * to assign focus to the first ancestor window that takes
334
     * to assign focus to the first ancestor window that takes
336
     * focus.  If no window will take focus, set focus to the
335
     * focus.  If no window will take focus, set focus to the
337
     * desktop.
336
     * desktop.
338
     */
337
     */
338
    Control control = null;
339
    boolean fixFocus = false;
340
    if( !enabled ) {
341
      control = display.getFocusControl();
342
      fixFocus = isFocusAncestor( control );
343
    }
339
    if( enabled ) {
344
    if( enabled ) {
340
      state &= ~DISABLED;
345
      state &= ~DISABLED;
341
    } else {
346
    } else {
342
      state |= DISABLED;
347
      state |= DISABLED;
343
    }
348
    }
349
    if( fixFocus ) {
350
      fixFocus( control );
351
    }
344
  }
352
  }
345
353
346
  /**
354
  /**
(-)js/org/eclipse/rwt/test/tests/WidgetTest.js (+9 lines)
Lines 524-529 Link Here
524
      }
524
      }
525
    } ),
525
    } ),
526
526
527
    testDisableOfFocused : function() {
528
      var button = new org.eclipse.rwt.widgets.Button( "push" );
529
      button.addToDocument();
530
      button.setFocused( true );
531
      assertTrue( button.getFocused() );
532
      button.setEnabled( false );
533
      assertFalse( button.getFocused() );
534
    },
535
527
    /////////
536
    /////////
528
    // Helper
537
    // Helper
529
    
538
    
(-)src/org/eclipse/swt/widgets/Control_Test.java (+10 lines)
Lines 616-621 Link Here
616
    assertTrue( noFocusControl.isFocusControl() );
616
    assertTrue( noFocusControl.isFocusControl() );
617
  }
617
  }
618
618
619
  public void testDisableOfFocused() {
620
    Control control = new Button( shell, SWT.PUSH );
621
    shell.open();
622
    control.setFocus();
623
624
    control.setEnabled( false );
625
626
    assertSame( shell, display.getFocusControl() );
627
  }
628
619
  public void testDisposeOfFocused() {
629
  public void testDisposeOfFocused() {
620
    Control control1 = new Button( shell, SWT.PUSH );
630
    Control control1 = new Button( shell, SWT.PUSH );
621
    Composite composite = new Composite( shell, SWT.NONE );
631
    Composite composite = new Composite( shell, SWT.NONE );

Return to bug 365396