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 290234 | Differences between
and this patch

Collapse All | Expand All

(-)source/class/qx/ui/core/Widget.js (-1 / +2 lines)
Lines 69-74 Link Here
69
    {
69
    {
70
      this._generateHtmlId();
70
      this._generateHtmlId();
71
    }
71
    }
72
    this.initHideFocus();
72
  },
73
  },
73
74
74
75
Lines 1659-1665 Link Here
1659
    hideFocus :
1660
    hideFocus :
1660
    {
1661
    {
1661
      check : "Boolean",
1662
      check : "Boolean",
1662
      init : false,
1663
      init : true,
1663
      apply : "_applyHideFocus",
1664
      apply : "_applyHideFocus",
1664
      themeable : true
1665
      themeable : true
1665
    },
1666
    },
(-)js/org/eclipse/rwt/widgets/Button.js (-1 / +51 lines)
Lines 25-31 Link Here
25
     case "radio":
25
     case "radio":
26
      this.setAppearance( "radio-button" );
26
      this.setAppearance( "radio-button" );
27
    }
27
    }
28
    this.initTabIndex();      
28
    this.initTabIndex();
29
    this.addEventListener( "focus", this._onFocus );
30
    this.addEventListener( "blur", this._onBlur );    
29
  },
31
  },
30
  
32
  
31
  properties : {
33
  properties : {
Lines 35-39 Link Here
35
      init : -1
37
      init : -1
36
    }
38
    }
37
        
39
        
40
  },
41
  
42
  members : {
43
44
    //overwritten
45
    _beforeRenderLayout : function( changes ) {
46
      if( this.hasState( "focused" ) ) {
47
        var focusIndicator = org.eclipse.rwt.FocusIndicator.getInstance(); 
48
        focusIndicator.update( this, this._getFocusIndicatorBounds() );
49
      }
50
    },
51
    
52
    _onFocus : function( event ) {
53
      var focusIndicator = org.eclipse.rwt.FocusIndicator.getInstance();
54
      focusIndicator.show( this, this._getFocusIndicatorBounds() );
55
    },
56
    
57
    _onBlur : function( event ) {
58
      var focusIndicator = org.eclipse.rwt.FocusIndicator.getInstance();
59
      focusIndicator.hide( this );
60
    },
61
    
62
    _getFocusIndicatorBounds : function() {
63
      var result = null;
64
      if( this.isCreated() ) {
65
        if(    ( this.hasState( "radio" ) || this.hasState( "check" ) )
66
            && ( this.getCellNode( 2 ) != null ) 
67
        ) {
68
          var node = this.getCellNode( 2 );
69
          var left = parseInt( node.style.left ) - 2;
70
          var top = parseInt( node.style.top ) - 2;
71
          var width = parseInt( node.style.width ) + 6;
72
          var height = parseInt( node.style.height ) + 6;
73
          result = [ left, top, width, height ];          
74
        } else {
75
          var node = this._getTargetNode();
76
          var left = 2;
77
          var top = 2;
78
          var width = parseInt( node.style.width ) - 4;
79
          var height = parseInt( node.style.height ) - 4;
80
          result = [ left, top, width, height ];          
81
        }
82
      } else {
83
        result = [ 0, 0, 0, 0 ];
84
      }
85
      return result;
86
    }
87
        
38
  }
88
  }
39
} );
89
} );
(-)src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java (+3 lines)
Lines 169-174 Link Here
169
    = "org/eclipse/swt/theme/ThemeStore.js";
169
    = "org/eclipse/swt/theme/ThemeStore.js";
170
  private static final String THEME_BORDERS_BASE
170
  private static final String THEME_BORDERS_BASE
171
    = "org/eclipse/swt/theme/BordersBase.js";
171
    = "org/eclipse/swt/theme/BordersBase.js";
172
  private static final String FOCUS_INDICATOR
173
  = "org/eclipse/rwt/FocusIndicator.js";
172
174
173
  private QooxdooResourcesUtil() {
175
  private QooxdooResourcesUtil() {
174
    // prevent intance creation
176
    // prevent intance creation
Lines 264-269 Link Here
264
      register( THEME_BORDERS_BASE, compress );
266
      register( THEME_BORDERS_BASE, compress );
265
      register( THEME_STORE, compress );
267
      register( THEME_STORE, compress );
266
      register( THEME_VALUES, compress );
268
      register( THEME_VALUES, compress );
269
      register( FOCUS_INDICATOR, compress );
267
270
268
      // register contributions
271
      // register contributions
269
      registerContributions();
272
      registerContributions();
(-)js/org/eclipse/rwt/FocusIndicator.js (+74 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     EclipseSource - ongoing development
10
 ******************************************************************************/
11
12
qx.Class.define( "org.eclipse.rwt.FocusIndicator", {
13
  type : "singleton",
14
  extend : qx.core.Object,
15
16
  construct : function() {
17
    this.base( arguments );
18
    this._frame = document.createElement( "div" );
19
    this._borderWidth = 1;
20
    this._frame.setAttribute( "id", "focusIndicator" );
21
    this._frame.style.position = "absolute";
22
    this._frame.style.zIndex = "1000000";
23
    this._frame.style.backgroundColor = "transparent";
24
    this._frame.style.fontSize = 0;
25
    this._frame.style.lineHeight = 0;    
26
    this._frame.style.border = this._borderWidth + "px dotted gray";
27
    this._parentNode = null;
28
    this._currentWidget = null;
29
  },
30
31
  members : {
32
    
33
    show : function( widget, bounds ) {
34
      this._hide();
35
      this._currentWidget = widget;
36
      if( widget.isCreated() ) {
37
        this._parentNode = widget._getTargetNode();
38
        this.update( widget, bounds );
39
      }
40
      // TODO [tb] : handle not yet created widgets (?)
41
    },
42
    
43
    update : function( widget, bounds ) {
44
      // Note : bounds are given as array [ left, top, width, height ]
45
      if( widget == this._currentWidget ) {
46
        if( this._frame.parentNode != this._parentNode ) {
47
          this._parentNode.appendChild( this._frame );
48
        }
49
        this._frame.style.left = bounds[ 0 ] + "px";
50
        this._frame.style.top = bounds[ 1 ] + "px";
51
        this._frame.style.width 
52
          = ( bounds[ 2 ] - this._borderWidth * 2 ) + "px";
53
        this._frame.style.height 
54
          = ( bounds[ 3 ] - this._borderWidth * 2 ) + "px";
55
      }
56
    },
57
    
58
    hide : function( widget ) {
59
      if( widget == this._currentWidget ) {
60
        this._hide();
61
        this._currentWidget = null;
62
      }
63
    },
64
    
65
    _hide : function() {
66
      if( this._frame.parentNode != null ) {
67
        this._frame.parentNode.removeChild( this._frame );
68
      }
69
      this._parentNode = null;
70
    }
71
72
  }
73
} );
74
(-)js/org/eclipse/rwt/test/tests/ButtonTest.js (-3 / +34 lines)
Lines 17-22 Link Here
17
  },
17
  },
18
  
18
  
19
  members : {
19
  members : {
20
        
21
    testFocusIndicator : function() {
22
      var hasFocusIndicator = function( widget ) {
23
        var node = widget._getTargetNode();
24
        var result = false;
25
        for( var i = 0; i < node.childNodes.length; i++ ) {
26
          if( node.childNodes[ i ].getAttribute( "id") == "focusIndicator" ) {
27
            result = true;
28
          }
29
        }
30
        return result;
31
      }
32
      var button = new org.eclipse.rwt.widgets.Button( "push" );
33
      this._currentButton = button;
34
      button.addToDocument();
35
      qx.ui.core.Widget.flushGlobalQueues();
36
      assertFalse( button.hasState( "focus" ) );
37
      assertFalse( hasFocusIndicator( button ) );
38
      button.focus();
39
      qx.ui.core.Widget.flushGlobalQueues();
40
      assertTrue( hasFocusIndicator( button ) );
41
      button.setImage( "test.jpg" );
42
      qx.ui.core.Widget.flushGlobalQueues();
43
      assertTrue( hasFocusIndicator( button ) );
44
      button.blur();
45
      qx.ui.core.Widget.flushGlobalQueues();
46
      assertFalse( hasFocusIndicator( button ) );
47
      button.destroy();
48
      qx.ui.core.Widget.flushGlobalQueues();
49
    },
50
        
20
    testParent : function() {
51
    testParent : function() {
21
      var button = new org.eclipse.rwt.widgets.Button( "push" );
52
      var button = new org.eclipse.rwt.widgets.Button( "push" );
22
      this._currentButton = button;
53
      this._currentButton = button;
Lines 33-39 Link Here
33
        button.getCellNode( 2 ).parentNode 
64
        button.getCellNode( 2 ).parentNode 
34
      );
65
      );
35
      button.setParent( null );
66
      button.setParent( null );
36
      button.dispose();
67
      button.destroy();
37
      qx.ui.core.Widget.flushGlobalQueues();
68
      qx.ui.core.Widget.flushGlobalQueues();
38
    },
69
    },
39
    
70
    
Lines 45-51 Link Here
45
      qx.ui.core.Widget.flushGlobalQueues();
76
      qx.ui.core.Widget.flushGlobalQueues();
46
      assertEquals( "Hello World!", button.getCellNode( 2 ).innerHTML );
77
      assertEquals( "Hello World!", button.getCellNode( 2 ).innerHTML );
47
      button.setParent( null );
78
      button.setParent( null );
48
      button.dispose();
79
      button.destroy();
49
      qx.ui.core.Widget.flushGlobalQueues();
80
      qx.ui.core.Widget.flushGlobalQueues();
50
    },
81
    },
51
    
82
    
Lines 59-65 Link Here
59
        this.testUtil.getCssBackgroundImage( button.getCellNode( 1 ) ).search( "test.jpg" ) != -1 
90
        this.testUtil.getCssBackgroundImage( button.getCellNode( 1 ) ).search( "test.jpg" ) != -1 
60
      );
91
      );
61
      button.setParent( null );
92
      button.setParent( null );
62
      button.dispose();
93
      button.destroy();
63
      qx.ui.core.Widget.flushGlobalQueues();
94
      qx.ui.core.Widget.flushGlobalQueues();
64
    },
95
    },
65
    
96
    
(-)js/resource/Includes.js (+1 lines)
Lines 70-75 Link Here
70
<script src="../org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/RadioButtonUtil.js" type="text/javascript"></script>\
70
<script src="../org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/RadioButtonUtil.js" type="text/javascript"></script>\
71
<script src="../org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/GfxMixin.js" type="text/javascript"></script>\
71
<script src="../org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/GfxMixin.js" type="text/javascript"></script>\
72
<script src="../org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/RoundedBorder.js" type="text/javascript"></script>\
72
<script src="../org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/RoundedBorder.js" type="text/javascript"></script>\
73
<script src="../org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/FocusIndicator.js" type="text/javascript"></script>\
73
\
74
\
74
<!-- rwt.test -->\
75
<!-- rwt.test -->\
75
<script src="./js/org/eclipse/rwt/test/fixture/RAPRequestPatch.js" type="text/javascript"></script>\
76
<script src="./js/org/eclipse/rwt/test/fixture/RAPRequestPatch.js" type="text/javascript"></script>\

Return to bug 290234